What\'s the explanation for the following:
public class GenericsTest {
//statement 1
public ArrayList[] lists;
public GenericsTes
So the actual question is: Why is there no error for declaring a generic array? ?
You will always get an error at the point you do something erroneous. Adding an error where there isn't technically a problem just adds to a clutter (although an editor might want to point that out to you).
In some circumstances you may want to bend the rules a bit with an unchecked cast. There's no need to force the code to be littered with more warning suppressions than necessary (other than to point out the folly).