Überladene Methoden in Java. Was kommt raus?

Interesantes Beispiel zum Thema überladen der Methoden.

public class Test {
    public static void foo(int a, int b) {
        System.out.print("A");
    }
    public static void foo(int... args) {
        System.out.print("B");
    }
    public static void foo(Integer... args) {
        System.out.print("C");
    }
    public static void main(String[] args) {
        foo(0, 1);
        foo((int) 0, 1);
        foo((Integer) 0, 1);
    }
}

Leave a Reply