posted 19 years ago Dear ranchers,
I have a query in the following question that I have customized a bit for testing purpose:
Given:-
Which statements could be inserted at // INSERT DECLARATION HERE to allow this code to compile and run? (Choose all that apply.)
A. List<List<Integer>> table = new List<List<Integer>>();
B. List<List<Integer>> table = new ArrayList<List<Integer>>();
C. List<List<Integer>> table = new ArrayList<ArrayList<Integer>>();
D. List<List, Integer> table = new List<List, Integer>();
E. List<List, Integer> table = new ArrayList<List, Integer>();
F. List<List, Integer> table = new ArrayList<ArrayList, Integer>();
G. None of the above.
Correct Answer is B.
What if I modify option C a bit to make it look like the following ..and try to recompile and run. But it doesn't compile, why? What is wrong with the type declaration here?
List<ArrayList<Integer>> table = new ArrayList<ArrayList<Integer>>();
-------------
Ravinder