All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
Hello, I've been trying to complete this question with less type parameters, I know is not the best answer but my code compiles and runs without errors or warnings while Enthuware tells me is wrong. I've got different right answers but this one is not working
private <E extends CharSequence> Collection<CharSequence> getWordsStartingWith(
Collection<E> input, char ch) {
Collection<CharSequence> returnValue = new ArrayList<CharSequence>();
int len = input.size();
for (E e : input) {
if (e.charAt(0) == ch)
returnValue.add(e);
}
return returnValue;
}
public void checkIt() {
List<String> a = new ArrayList<String>();
a.add("apple");
a.add("cherry");
Set<StringBuffer> b = new HashSet<StringBuffer>();
b.add(new StringBuffer("pineapple"));
Collection<CharSequence> ac = getWordsStartingWith(a, 'a');
Collection<CharSequence> bc = getWordsStartingWith(b, 'a');
System.out.println(ac);
System.out.println(bc);
}