Community
Participate
Working Groups
I20050202-0800-win32 Inside the following method: public static <T> void myMethod(final List<? extends File> fileList) I attempt to sort the list using: Collections.sort(fileList, new Comparator<File>(){...}); I get the following error: "The method sort(List<T>) in the type Collections is not applicable for the arguments (List<? extends File>, new Comparator<File>(){})" The Collections.sort() signature is: public static <T> void sort(List<T> list, Comparator<? super T> c) Substituting, I get (File super (? extends File)), which means Comparator<File> should match the signature because File is always a superclass of anything that extends File. This worked under 3.1 M4. Garret
Following test case compiles without any error: import java.io.File; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Test { public static <T> void myMethod(final List<? extends File> fileList) { Collections.sort(fileList, new Comparator<File>(){ public int compare(File f1, File f2) { return 0; } }); } } Surely fixed with latest 1.5 changes...
Yes---I've verified this now compiles under 3.1 M5. Garret