both replies make the code compile.
I think Sigrid is unclearof the difference between typesafeing a collection and templating a method.
when you are
declaring a type safe collection you can use notation like:
ArrayList<? extends CharSequence> ,
but when you are
templating a method or a class you use notation like <T extends CharSequence>
also be careful of the the method below,
the collection passed to the method will not determine what T is.
It is left to the return type to do this. ie you could pass in Collection<StringBuffer> and return Collection<
String>.
public static <T extends CharSequence>
Collection<T> getLongWords(Collection<? extends CharSequence> coll) in the method below the type of collection passed and returned would be the same:
public static <T extends CharSequence>
Collection<T> getLongWords(Collection<T> coll) [ April 15, 2007: Message edited by: Louis Moloney ]