If I have an Employee class and used as a key in HashMap and if I am using same variables for both object then how map finds duplicate key?
public class Employee {
    int id;
    String name;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
}
Main class
public class EmployeeTest {
    public static void main(String[] args) {
        Employee e1 = new Employee();
        e1.setId(100);
        e1.setName("abc");
        Employee e2 = new Employee();
        e2.setId(100);
        e2.setName("xyz");
        Map<Employee, Integer> map = new HashMap<Employee, Integer>();
        map.put(e1, 1);
        map.put(e2, 2);
    }
    
}
Is e2 a duplicate object or adding new entry in map?
 
    