Skip to main content

Autoboxing vs. widening quiz

Posted by staufferjames on December 18, 2007 at 7:59 AM PST

Does widening or autoboxing happen first? Which param method will be called from the autoboxing method? If one param method is commented out then it will have no problem calling the other.

private static void autoboxing() {
    Integer integer = new Integer(2);
    param(integer);
}

private static void param(int param) {
    System.out.println("param(int " + param + ")");
}

private static void param(Object param) {
    System.out.println("param(Object " + param + ")");
}
Related Topics >>