• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Convert String to char[] got unexpected result

 
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Output:

s = "ABCDEFG" a = "[C@604c9c17"
s.length() = 7 a.length = 7
s.charAt(0) = A a=[0] = A
s.charAt(1) = B a=[1] = B
s.charAt(2) = C a=[2] = C
s.charAt(3) = D a=[3] = D
s.charAt(4) = E a=[4] = E
s.charAt(5) = F a=[5] = F
s.charAt(6) = G a=[6] = G
>
 
Marshal
Posts: 80749
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is unexpected about that? What did you expect and what was different? Have you read what the members of an array type are? They are all in the Java® Language Specification, but that can be difficult to understand. Look particularly what the toString method is.
reply
    Bookmark Topic Watch Topic
  • New Topic