I wrote this program but its giving o/p as false,false only without duplicates.
public static void main(String[] args)
{
HashSet hh = new HashSet();
String aa = new String("a");
String bb...
Type: Posts; User: tcstcs
I wrote this program but its giving o/p as false,false only without duplicates.
public static void main(String[] args)
{
HashSet hh = new HashSet();
String aa = new String("a");
String bb...
with the program, we will not be able to see the results. Reason being
If set has {a,s,d,f}
I will add 's' to set and after addition it will be {a,s,d,f}
So we will not know whether its prev 's'...
HashSet is implemented with HashMap. So in HashMap, if i add element with existing key the older value gets replaced with new one. Then in set as its based on HashMap, older value should be replaced...
In a set if we have 5 objects {'a','v','d','w','r'}
And if i add one more same element say 'd', will the earlier 'd' object be retained in Set or it will be replaced by new 'd' object.