• Post Reply Bookmark Topic Watch Topic
  • New Topic

multidimensional irregular array  RSS feed

 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made an array which is multidimensional and irregular.How can i print values without having to call each index manually.I mean,how to write the "System.out.println" statement once and get the whole output
here is my code for array initialisation...
int b[][]={{0,1},{2,3,4,5},{6,7,8}};


please help
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jitendra Jha:
I have made an array which is multidimensional and irregular.How can i print values without having to call each index manually.I mean,how to write the "System.out.println" statement once and get the whole output
here is my code for array initialisation...
int b[][]={{0,1},{2,3,4,5},{6,7,8}};


Unfortunately, the toString() method of an array, just returns a value that doesn't include the elements, so you have no choice but to print all the elements.

But what do you mean by "call each index manually"? It's just a pair of nested loops -- which is probably how it would have been done if the array's toString() method did it.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!