← Back to Question List
Java Code Walkthrough #38
Generic Identity Method
📄 Code
Read carefully — what does this print?1public class Main {2 public static <T> T identity(T value) {3 return value;4 }56 public static void main(String[] args) {7 String s = identity("world");8 int n = identity(7);9 System.out.println(s);10 System.out.println(n);11 }12}