Type a runtime check that two generic lists share the same class
Type a runtime check that two generic lists share the same class
Answer
List<String> ss = new ArrayList<>(); List<Integer> ii = new ArrayList<>(); System.out.println(ss.getClass() == ii.getClass()); // true
Type arguments are erased from bytecode. Both ArrayList<String> and ArrayList<Integer> become ArrayList at runtime.