title: Unexpected result from arrays java
body: <p>Write a program that return the first 3 numbers greater than 11. If there are fewer than 3 numbers greater than 11, then return as many as you find. You will always return an array size 3. Zeroes will fill the array if there are not 3 numbers greater than 11. This is the code that i write but it giving unexpected answer. Can anyone correct this code.</p>
  
  <pre><code>public class RayGetNums
  {
      //method go will return an array
      //containing the first 3 numbers
      //greater than 11
  public static int[] go(int[] ray)
  {
      int[] res = new int[]{0,0,0};
      int count = 0;
      for (int i = 0; i &lt; ray.length &amp;&amp; count &lt; 3; i++) {
          if ( ray[i] &gt; 11 ) {
              res[count++] = ray[i];
          }
      }
      return res;
  }
  }
  </code></pre>
  
  <p>The Runner that i use with this question is this:</p>
  
  <pre><code>class Runner
   {
    public static void main(String[] args)
    {
      RayGetNums rt = new RayGetNums();
  
          System.out.println( rt.go( new int[]{-99,1,2,3,4,5,6,7,8,9,10,12345} ) );
          System.out.println( rt.go( new int[]{10,9,8,7,6,5,4,3,2,1,-99} ) );
          System.out.println( rt.go( new int[]{10,20,30,40,50,-11818,40,30,20,10} ) );
          System.out.println( rt.go( new int[]{32767} ) );
          System.out.println( rt.go( new int[]{255,255} ) );
          System.out.println( rt.go( new int[]{9,10,-88,100,-555,1000} ) );
          System.out.println( rt.go( new int[]{10,10,10,11,456} ) );
          System.out.println( rt.go( new int[]{-111,1,2,3,9,11,20,30} ) );
          System.out.println( rt.go( new int[]{9,8,7,6,5,4,3,2,0,-2,-989} ) );
          System.out.println( rt.go( new int[]{12,15,18,21,23,1000} ) );
          System.out.println( rt.go( new int[]{250,19,17,15,13,11,10,9,6,3,2,1,-455} ) ); 
          System.out.println( rt.go( new int[]{9,10,-8,10000,-5000,1000} ) );
    }
  }
  </code></pre>
  
  <p>The answers that i get with this code is:</p>
  
  <pre><code>[I@4617c264
  [I@36baf30c
  [I@7a81197d
  [I@5ca881b5
  [I@24d46ca6
  [I@4517d9a3
  [I@372f7a8d
  [I@2f92e0f4
  [I@28a418fc
  [I@5305068a
  [I@1f32e575
  [I@279f2327
  </code></pre>
  
  <p>The answers that i need we this runner:</p>
  
  <pre><code>[12345, 0, 0]
  [0, 0, 0]
  [20, 30, 40]
  [32767, 0, 0]
  [255, 255, 0]
  [100, 1000, 0]
  [456, 0, 0]
  [20, 30, 0]
  [0, 0, 0]
  [12, 15, 18]
  [250, 19, 17]
  [10000, 1000, 0]
  </code></pre>
  
  <p>Can anyone correct the error so i have correct answers.
  Thank you</p>