I've been getting odd compile errors when trying to sort while using
generics.
I have the following code:
static final List<Class> levelList;
static {
Vector<Class> v = new Vector<Class>();
v.add(myClass1.class);
v.add(myClass2.class);
v.add(myClass3.class);
Collections.sort(v);
levelList = Collections.unmodifiableList(v);
}
which causes the compile error:
C:\dev\cvs.kitfox.com\scarlet\src\com\kitfox\scarl et\levels\ScarletLevelList.java:34:
cannot find symbol
symbol : method sort(java.util.List<java.lang.Class>)
location: class java.util.Collections
Collections.sort((List<Class>)v);
However, if I change the sort command to
Collections.sort((List)v);
Things work. Is there a way to write the above code so that it
compiles correctly with generics?
Mark McKay
--
http://www.kitfox.com