What will the program print when compiled and run?
public class Main { public static void main(String[] args) { List<String> lst1 = new ArrayList<String>(); List<Integer> lst2 = new ArrayList<Integer>(); List<List<Integer>> lst3 = new ArrayList<List<Integer>>(); System.out.print(lst1.getClass() + " "); System.out.print(lst2.getClass() + " "); System.out.println(lst3.getClass()); }/*from ww w.ja v a2s . c om*/ }
Select the one correct answer.
(b)
It is the fully qualified name of the class after erasure that is printed at runtime.
Note that it is the type of the object, not the reference, that is printed.
The erasure of all the lists in the program is ArrayList.