import java.util.Iterator;
import java.util.*;
public class HashSetDemo
{
public static void main(String[] args)
{
HashSet<Integer> intSet = new HashSet<Integer>();
intSet.add(2);
intSet.add(7);
intSet.add(7);
intSet.add(3);
intSet.add(4);
intSet.add(9);
intSet.add(1);
intSet.add(13);
System.out.println(intSet);
intSet.remove(1);
System.out.println(intSet);
I have written the above code to implement HashSet but when I run it, I always get the output in ascending order. I am unable to understand why is this happening as a HashSet doesn't order it's elements.