I have the following statements :
List<List<String>> myList = new ArrayList<ArrayList<String>>();
List<ArrayList<String>> myList = new ArrayList<ArrayList<String>>();
The first one gives compile error. Shouldn’t we code to interface? Here I am forced to code by class not the interface. Is this a generics failure, or I am understanding it wrong?
This is a known problem. It would have other problems if you do this.
Consider this code: