Page 1 of 1

About Question enthuware.ocpjp.v7.2.1310 :

Posted: Mon Mar 31, 2014 4:46 am
by jaypi
This is a valid (yet refused) answer:

Code: Select all

public class TestClass {

	public static void main(String[] args) {
		Set<String> holder = new TreeSet<>();
		holder.add("tom");
		holder.add("dick");
		holder.add("harry");
		holder.add("tom");
		printIt(holder);
	}

	public static void printIt(Collection<String> list) {
		for (String s: list) System.out.println(s);
	}

}

Re: About Question enthuware.ocpjp.v7.2.1310 :

Posted: Mon Mar 31, 2014 5:06 am
by admin
Yes, it is valid but you need to fill all the yellow drag targets. So you need to put TreeSet<String> instead of TreeSet<>.

HTH,
Paul.

Re: About Question enthuware.ocpjp.v7.2.1310 :

Posted: Tue Aug 19, 2014 2:50 pm
by bluster
My compiler was happy with this (rebuffed) one, producing the expected output.

Code: Select all

public class TestClass {

   public static void main(String[] args) {
      Set<String> holder = new TreeSet<String>();
      holder.add("tom");
      holder.add("dick");
      holder.add("harry");
      holder.add("tom");
      printIt(holder);
   }

   public static void printIt(Collection<String> list) {
      for (String s: list) System.out.println(s);
   }

}
Also, the solution filled all the yellow drag targets. Thirdly, the explanation goes with
can be Collection<String> or any subclass of Collection<String> such as Set<String>.


Can someone tell me what condition was not fulfilled to have the answer considered OK? Thanks!

Re: About Question enthuware.ocpjp.v7.2.1310 :

Posted: Tue Aug 19, 2014 7:45 pm
by admin
I tried the same and it was evaluated as correct. May be you had a typo in TreeSet?
-Paul.

Re: About Question enthuware.ocpjp.v7.2.1310 :

Posted: Wed Aug 20, 2014 12:12 pm
by bluster
It could have been that. Thanks for checking!

Re: About Question enthuware.ocpjp.v7.2.1310 :

Posted: Tue Jul 04, 2017 9:45 am
by AndaRO
I can't drag 'Set' keyword.

Re: About Question enthuware.ocpjp.v7.2.1310 :

Posted: Tue Jul 04, 2017 10:52 pm
by admin
I tried it just now. Seems to be working fine. Try taking it close to the yellow target and it should go there.
-Paul.