Thanks Jeroen for clearing my doubt i have one more doubt i have written a piece of code
import java.util.*;
public class TestHashSet {
public static void main(
String args[]) {
Set set = new HashSet();
set.add("Bill");
set.add("Henrry Ford");
set.add("Bill");
set.add("Brian");
set.add("Gates");
System.out.println(set);
System.out.println("size"+set.size());
Iterator itr = set.iterator();
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
}
Output:[Brain,Bill,Henrry Ford,Gates]
Size:4
Brain
Bill
Henrry Ford
Gates
Now my question is why it is not showing the set values in the order they are inserted in set.Using the same example for list i got the result in order in which i have inserted the value then why not for set.
Regards
Rashi