Page 1 of 1

About Question enthuware.ocpjp.v8.2.1309 :

Posted: Sun Oct 09, 2016 12:42 pm
by emer11
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

Code: Select all

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);
	}

Re: About Question enthuware.ocpjp.v8.2.1309 :

Posted: Sun Oct 09, 2016 4:13 pm
by admin
You are right. This should be set as correct answer as well. Fixed.
thank you for your feedback!
Paul.

Re: About Question enthuware.ocpjp.v8.2.1309 :

Posted: Sun Oct 09, 2016 7:48 pm
by emer11
Thanks for your prompt answer Paul.