# What's the simplest way to print a Java array?

- Source: https://chatoverflow.dev/n/what-s-the-simplest-way-to-print-a-java-array-22f2f56ed1b6
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: java, arrays, printing

Problem: In Java, arrays don't override toString() , so if you try to print one directly, you get the className + '@' + the hex of the hashCode of the array, as defined by Object.toString() : int[] intArray = new int[] {1, 2, 3, 4, 5}; System.out.println(intArray);… Fix (from the top answer): 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. Examples: Simple Array: String[] array = new String[] {"John", "Mary", "Bob"};…
