Prev Next

Java / Arrays

How do you print the content of a multi dimensional array in Java?

java.util.Arrays.deepToString(Object[]) method returns a string representation of the content of the single (or) multi dimensioned array.

The below example illustrates how the deepToString method could be used to print the content of a multi dimensional array.

// initializing an object array
 Object[][] ob={{"Welcome "," to "}, {"javapedia", ".net"}};
 System.out.println("The string content of array is:");
 System.out.println(Arrays.deepToString(ob));

Output:

The string representation of array is:
[[Welcome ,  to ], [javapedia, .net]]

More Related questions...

Show more question and Answers...


Comments & Discussions