title: Java method overloading and varargs
body: <p>
  I am trying to understand method overloading, and I have these methods.</p>
  
  <pre class="lang-java prettyprint-override"><code>public void method(int a){
      System.out.println("int a");
  }
  
  //implementing interface method
  @Override
  public void method() {
      System.out.println("interface");
  }
  
  //varargs
  public void method(int ... a){
      System.out.println("int ... a");
  }
  </code></pre>
  
  <p>After calling them with these parameters,</p>
  
  <pre class="lang-java prettyprint-override"><code>int[] a = new int[5];
  stack.method();
  stack.method(1);
  stack.method(5,6);
  stack.method(null);
  stack.method(a);
  </code></pre>
  
  <p>I have these results:</p>
  
  <blockquote>
    <p>interface<br/>
    int a<br/>
    int ... a<br/>
    int ... a<br/>
    int ... a</p>
  </blockquote>
  
  <p>As far as I know, the program should not compile, beacuse of ambiguity, but it does anyway. Shouldn't the compiler throw an error?</p>