• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recursively dumping the contents of a collection or an array to standard output in Java.  RSS feed

 
Abhijit Ghatnekar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Is there a way to recursively dump the contents of a collection - any collection or an array for that matter to standard output in Java ?

In PHP, there's a library function called print_r/var_dump that does the same enabling us to inspect the composite datatype's structure before it could be looped over..
in Perl, the same thing could be achieved through a package Data::Dumper.

How about Java? Is there an equivalent of this in Java ?

Regds,
Abhijit.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried something like:

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For arrays there's java.util.Arrays.toString() and deepToString()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!