LogiQuest
Back to Generics
9

What is the output of the following program?

public 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(4, 9) + " " + max("kiwi", "apple"));
    }
}
Medium

Discussion (0)

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

Log in to join the discussion.