• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

recursive problem

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use:
 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Dinner will be steamed monkey heads with a side of tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic