I want to understand the difference between the two definitions and why the correct one is correct and the wrong is wrong.
The one showing me the compile-error
List<List<Integer>> arr2 = new ArrayList<ArrayList<Integer>>();
The error it gave me :
try2.java:8: error: incompatible types: ArrayList<ArrayList<Integer>> cannot be
converted to List<List<Integer>>
List<List<Integer>> arr2 = new ArrayList<ArrayList<Integer>>();
The one which is working:
List<ArrayList<Integer>> arr = new ArrayList<ArrayList<Integer>>();
NOTE:
I understand why the below one works:
List<Integer> arr = new ArrayList<Integer>();
Edit-1:
Now i just want to understand what is wrong with List<List<Integer>> arr2 = new ArrayList<ArrayList<Integer>>();
>` is sufficient enough for type correctness
– SomeJavaGuy Jul 26 '17 at 06:44> arr2 = new ArrayList
– Jesper Jul 26 '17 at 06:46>();`