• Post Reply Bookmark Topic Watch Topic
  • New Topic

recursive problem  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm having a problem with my code... i don't know what to do with it...
it displays stuff like [{09gsd.... how can i make it display the array elements?
thank you!

 
Marshal
Posts: 5657
769
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Momo Sawada wrote:


Printing an array object doesn't print the containing elements. You can use a for-loop to iterate over the array and print each elements of it.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Momo Sawada wrote: . . . it displays stuff like [{09gsd.... how can i make it display the array elements? . . .
If you go through the Java™ Language Specification, you find that an array has . . .
All the members inherited from class Object; the only method of Object that is not inherited is its clone method.
That means it has an un-overridden toString() method. Clicking that last link tells you that you get a printout in the format ClassName@123abc45, which in the case of an array looks like [ClassName@8734eb2a or something. Note that primitive arrays start with [ and one letter, I think chosen from BCDFILSZ. All arrays have an initial [, and I think arrays of arrays start with [[, and similarly more [][][] in the code will produce more [[[ in the printout.
 
Campbell Ritchie
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devaka Cooray wrote:. . . You can use a for-loop to iterate over the array and print each elements of it.
Lots more information in the Java™ Tutorials, here and here.
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use:
 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devaka Cooray wrote:
Momo Sawada wrote:


Printing an array object doesn't print the containing elements. You can use a for-loop to iterate over the array and print each elements of it.


lol... i almost forgot that... i can't believe i didn't remember it when i had just used it...
thanks a lot!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!