collections set &list interfaces...
narsimhaSun Jul 01, 2012 11:23 AM
How can you say set will not allow duplicates?how can you remove duplicate elements from list?
Report | Quote This | Send private message | Reply | Print
Hi Narsinmha ,
The basic characteristic of set is to allow only unique values in collection and Set make sure that using the equals method of the elements being added. So let say if you are adding Person object and if you implement proper equals and hashcode methods then Set will make use of this equals and hashcode methods to make sure that elements are unique.
Ans to Q 2: Just copy all your element in Set to remove duplicates