Page 1 of 1
About Question enthuware.ocpjp.v8.2.1585 :
Posted: Fri May 13, 2016 1:46 pm
by karlharb
One of the answers to this question is:
The order of elements while iteration remains the same always.
This statement does not make sense, as far as I can see?
Re: About Question enthuware.ocpjp.v8.2.1585 :
Posted: Fri May 13, 2016 8:53 pm
by admin
It means that when you iterate through the elements in a HashSet, you get the elements in the same order no matter how many times you iterate. For example, if you iterate through a HashSet and if you get A, B, C first time, then if you iterate again, you will still get A, B, C. You will not get A, C, B.
This is of course incorrect (as given in the explanation) because HashSet does not guarantee this behavior.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v8.2.1585 :
Posted: Fri Aug 17, 2018 8:56 am
by Touciuciu
This explanation for this question is incorrect (second choice) or confussing:
No Set (HashSet, TreeSet, or any other implementation of Set interface) allows duplicate elements.
Re: About Question enthuware.ocpjp.v8.2.1585 :
Posted: Fri Aug 17, 2018 10:13 am
by admin
Why do you think it is incorrect?
Re: About Question enthuware.ocpjp.v8.2.1585 :
Posted: Tue Aug 21, 2018 3:08 am
by Touciuciu
What I understand from this answear is that Set allows duplicate elements which is incorrect.
I think the correct form should be:
Set (HashSet, TreeSet, or any other implementation of Set interface) does not allow duplicate elements.
It is kind of the same but more concrete and not at all confussing