About Question enthuware.ocpjp.v8.2.1309 :

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.

Moderators: Site Manager, fjwalraven

Post Reply
emer11
Posts: 2
Joined: Fri Sep 23, 2016 8:13 am
Contact:

About Question enthuware.ocpjp.v8.2.1309 :

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

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You are right. This should be set as correct answer as well. Fixed.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

emer11
Posts: 2
Joined: Fri Sep 23, 2016 8:13 am
Contact:

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

Post by emer11 »

Thanks for your prompt answer Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests