← Back to Question List
Java Code Walkthrough #41
Generic Max of Two Values
📄 Code
Read carefully — what does this print?1public class Main {2 public static <T extends Comparable<T>> T max(T a, T b) {3 if (a.compareTo(b) >= 0) {4 return a;5 }6 return b;7 }89 public static void main(String[] args) {10 System.out.println(max(8, 3));11 System.out.println(max("apple", "banana"));12 }13}