title: Method return Double instead of Integer
body: <pre><code>  private Integer[] array = new Integer[]{1, 2, 3, 4};
  
      Number getValueByIndex(int index)
      {
          return (index &gt;= 0 &amp;&amp; index &lt; array.length) ? array[index] : new Double(-1);
      }
  
      public static void main(String[] args)
      {
          Number value1 = new Solution().getValueByIndex(5); //-1.0, class java.lang.Double expected
          Number value2 = new Solution().getValueByIndex(2); //3, class java.lang.Integer expected
  
          System.out.println(value1 + ", " + value1.getClass().toString());
          System.out.println(value2 + ", " + value2.getClass().toString());
      }
  </code></pre>
  
  <p>I can't figure out why the method return Double instead of Integer in the second case.</p>