??????????????У?????????????hashCode??equals?????????????????????????????????????????д?????????????Apache Commons?????????????????

????hashCode()??equals()??????Object???У????????????java?????????????е?java?????????????????

???????hashCode()??equals()

????hashCode()?????????????????????????????????????????????????洢??HashTable???????е?λ?á??????Object???hashCode()???????????????洢????????????

??????д???????

???????????д?????????????????????????κ??????????е????????????????????Щ????????????

????????????????????????????????????Employee

    public class Employee 
    { 
        private Integer id; 
        private String firstname; 
        private String lastName; 
        private String department; 
        public Integer getId() { 
            return id; 
        } 
        public void setId(Integer id) { 
            this.id = id; 
        } 
        public String getFirstname() { 
            return firstname; 
        } 
        public void setFirstname(String firstname) { 
            this.firstname = firstname; 
        } 
        public String getLastName() { 
            return lastName; 
        } 
        public void setLastName(String lastName) { 
            this.lastName = lastName; 
        } 
        public String getDepartment() { 
            return department; 
        } 
        public void setDepartment(String department) { 
            this.department = department; 
        } 
    }

?????????Employee????????Щ??????????????getter??setter???????????????????????????employee?????Ρ?

    public class EqualsTest { 
        public static void main(String[] args) { 
            Employee e1 = new Employee(); 
            Employee e2 = new Employee(); 
            e1.setId(100); 
            e2.setId(100); 
            //Prints false in console
            System.out.println(e1.equals(e2)); 
        } 
    }