• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Convert String to char[] got unexpected result

 
Ranch Hand
Posts: 255
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: 73994
332
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic