About Question enthuware.ocpjp.v7.2.1309 :
Posted: Tue Jan 06, 2015 11:31 am
This snippet is from the explanation:
This is my modification:
I moved <E extends CharSequence> from the method to class. The class looks good, but the usage is wrong.
Collection<String> ac = getWordsStartingWith(a, 'a');
Error:
Code: Select all
public class TestClass {
public <E extends CharSequence> Collection<E> getWordsStartingWith(
Collection<E> input, char ch)
Code: Select all
public class TestClass <E extends CharSequence> {
public Collection<E> getWordsStartingWith(
Collection<E> input, char ch)
Collection<String> ac = getWordsStartingWith(a, 'a');
Error:
Could you explain the difference please?The method getWordsStartingWith(Collection<E>, char) in the type TestClass<E> is not applicable for the arguments (List<String>, char)