Page 1 of 1

About Question com.enthuware.ets.scjp.v6.1.815 :

Posted: Thu Oct 20, 2011 9:30 pm
by ETS User
I don't think this is right. Please correct me if I am wrong, but here is what I have.

Step 1:
s = [324, 325, 326, 327, 328]
sub = [326, 327, 328] // because the true,true it should include both 326 and 328

add 329.


s = [324, 325, 326, 327, 328, 329]
sub = [326, 327, 328] // because 329 is out of range of the subset


If I am wrong, can you tell me how the true, true values work in .subSet??

thanks

Re: About Question com.enthuware.ets.scjp.v6.1.815 :

Posted: Fri Oct 21, 2011 8:01 am
by admin
The important point to understand here is that returned subset is backed by the original set and it is constrained by the range given while its creation. It is not a new set in which you can add anything. Therefore, you cannot add 329 to this subset because it will violate the range for which this subset was created.

HTH,
Paul.

Re: About Question com.enthuware.ets.scjp.v6.1.815 :

Posted: Sun Oct 26, 2014 5:34 pm
by piotrkmiotczyk
What type of object is returned by subSet?

Re: About Question com.enthuware.ets.scjp.v6.1.815 :

Posted: Sun Oct 26, 2014 7:37 pm
by admin
That depends on the class of Set on which you call subSet. You will need to chect the javadoc for that class.