On the right hand side, can we put this List<String>, like this List<List<String>> matrix = new ArrayList<List<String>>();?
The reason why I raise this question because this can make a good exam question.
Stephan van Hulst
Joined: Sep 20, 2010
Yes you could do that, but as of Java 7 it's unnecessary. The compiler can determine what the type arguments of the ArrayList should be from the variable you're trying to assign it to. All you have to do is use the diamond operator <>.