it says
public static <E extends CharSequence> Collection<? extends CharSequence>
getLongWords(Collection<E> coll)
is wrong
when inserted in this
import java.util.*;
public class LongWordFinder {
public static void main(
String[] args) {
String[] array = { "123", "12345678", "1", "12", "1234567890"};
List<String> list = Arrays.asList(array);
Collection<String> resultList = getLongWords(list);
}
// INSERT DECLARATION HERE
{
Collection<E> longWords = new ArrayList<E>();
for (E
word : coll)
if (word.length() > 6) longWords.add(word);
return longWords;
}
}
I think this must be a mistake, cause it compiles fine for me.
I am pretty sure you can use wildcards in your return type for generics.