What\'s the explanation for the following:
public class GenericsTest {
//statement 1
public ArrayList[] lists;
public GenericsTes
In this case, I would avoid using arrays for just this reason. The declaration of "lists" in your original code could be
List> lists = new ArrayList>(4);
for(int i = 0; i < 4; i++) lists.add(null); // or add an empty ArrayList
(you should use the interface rather than the implementation in variable declarations)
Instead of array [] syntax, you would use get() or set(). Other than that, it's equivalent.