I'd want to write a method for returning a sorted list from a passed one.
This is more easier to write than to explain :-)
Everything seems quite straightforward, but I don't understand why the compiler seems not to connect the input type to the output.
Thanks!
Saverio M.
------------------------------------------------------------------
class C2 implements Comparable { ... }
class ArrayComparator<T extends Comparable> implements Comparator<T[]> { ... }
public static void main(
String... args)
{
List<C2> list = new ArrayList<C2>();
List<C2> listCopy = getSortedCopy(list);
}
private static <T extends Comparable> List<T[]> getSortedCopy(
List<T[]> data)
{
List<T[]> dataCopy = new ArrayList<T[]>(data);
Comparator<T[]> arrayComparator = new ArrayComparator<T>(dataCopy);
Collections.sort(dataCopy, arrayComparator);
return dataCopy;
}