title: How to convert an int array to String with toString method in Java
body: <p>I am using trying to use the <code>toString(int[])</code> method, but I think I am doing it wrong:</p>
  
  <p><a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Arrays.html#toString%28int%5B%5D%29" rel="noreferrer">http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Arrays.html#toString(int[])</a></p>
  
  <p>My code:</p>
  
  <pre><code>int[] array = new int[lnr.getLineNumber() + 1];
  int i = 0;
  
  System.out.println(array.toString());
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>[I@23fc4bec
  </code></pre>
  
  <p>Also I tried printing like this, but:</p>
  
  <pre><code>System.out.println(new String().toString(array));  // **error on next line**
  The method toString() in the type String is not applicable for the arguments (int[])
  </code></pre>
  
  <p><strong>I took this code out of bigger and more complex code, but I can add it if needed. But this should give general information.</strong></p>
  
  <p>I am looking for output, like in Oracle's documentation:</p>
  
  <blockquote>
    <p>The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). </p>
  </blockquote>