Can anyone explain the problem with this? The 'foo' class fails to compile with an 'incompatible types' error. If you replace 'UniqueList' with 'ArrayList', it works correctly, even though UniqueList is an unmodified subclass of 'ArrayList'. 'Column' is a class defined in the app, and I don't see how its details would matter.
public class UniqueList<E> extends ArrayList<E> {}
public class foo {
protected UniqueList<Column> a = new UniqueList<Column>();
public void bar (){
for (Column c : a) {
}
}
}
I realize that according to Java goodness rules, the definition of 'a' should refer to the interface 'List', but that causes an 'unchecked conversion' warning on that line. Which I also don't really understand despite Googling about that error for a while (most posts assume you are pre-generics and are missing the qualifier).
Thanks as always.