LogiQuest
Back to Generics
3

What is the output of the following program?

class Main {
    static <T extends Comparable<T>> T max(T a, T b) { return a.compareTo(b) >= 0 ? a : b; }
    public static void main(String[] args) { System.out.println(max(3, 9) + " " + max("pear", "apple")); }
}
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.