Why am I getting output 2 for the following code instead of 1? HashSet does not allow duplicate elements.
import java.util.*;
import java.io.*;
import java.math.*;
public class Main1
{
    static class pair 
    {
       int x;
       int y;
       public pair (int k, int p) 
       {
           x = k;
           y = p;
       }
    }
    public static void main(String[] args)throws IOException
    {
        Set<pair> hs=new HashSet<pair>();
        hs.add(new pair(1,2));
        hs.add(new pair(1,2));
        System.out.println(hs.size());
    }
}
 
     
    