Strange behavior when overloading methods in Java
<p>I came across this weird (in my opinion) behavior today. Take this simple Test class:</p>

<pre><code>public class Test {

public static void main(String[] args) {
    Test t = new Test();
    t.run();
}

private void run() {
    List&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
    list.add(new Object());
    list.add(new Object());
    method(list);
}

public void method(Object o) {
    System.out.println("Object");
}

public void method(List&lt;Object&gt; o) {
    System.out.println("List of Objects");
}
}
</code></pre>

<p>It behaves the way you expect, printing "List of Objects". But if you change the following three lines:</p>

<pre><code>List&lt;String&gt; list = new ArrayList&lt;String&gt;();
list.add("");
list.add("");
</code></pre>

<p>you will get "Object" instead.</p>

<p>I tried this a few other ways and got the same result. Is this a bug or is it a normal behavior? And if it is normal, can someone explain why?</p>

<p>Thanks.</p>
