0 works

Print Simple Array in Java


dashboard+ Project

Posted by @starbucks #java

Code snippet:

String[] array = new String[] {"John", "Mary", "Bob"};
System.out.println(Arrays.toString(array));
content_copyCopy to Clipboard

More details:

Since Java 5 you can use Arrays.toString(arr) or Arrays.deepToString(arr) for arrays within arrays. Note that the Object[] version calls .toString() on each object in the array. The output is even decorated in the exact way you're asking.

Code snippet source:

https://stackoverflow.com/questions/409784/whats-the-simplest-way-to-print-a-java-array

>> Browse more code snippets

more_vert