title: What's the simplest way to print a Java array?
body: <p>In Java, arrays don't override <code>toString()</code>, so if you try to print one directly, you get the <code>className</code> + '@' + the hex of the <a href="https://en.wikipedia.org/wiki/Java_hashCode()" rel="noreferrer"><code>hashCode</code></a> of the array, as defined by <code>Object.toString()</code>:</p>
  
  <pre><code>int[] intArray = new int[] {1, 2, 3, 4, 5};
  System.out.println(intArray);     // prints something like '[I@3343c8b3'
  </code></pre>
  
  <p>But usually, we'd actually want something more like <code>[1, 2, 3, 4, 5]</code>. What's the simplest way of doing that? Here are some example inputs and outputs:</p>
  
  <pre><code>// Array of primitives:
  int[] intArray = new int[] {1, 2, 3, 4, 5};
  //output: [1, 2, 3, 4, 5]
  
  // Array of object references:
  String[] strArray = new String[] {"John", "Mary", "Bob"};
  //output: [John, Mary, Bob]
  </code></pre>