...
Code Block | ||
---|---|---|
| ||
// Mutable class Employee class Employee { private String name; private double salary; Employee(String empName, double empSalary) { this.name = empName; this.salary = empSalary; } public void setEmployeeName(String empName) { this.name = empName; } // ... including a hashCode implementationpublic void setSalary(double empSalary) { this.salary = empSalary; } @Override public boolean equals(Object o) { if (!(o instanceof Employee)) { return false; } Employee emp = (Employee)o; return emp.name.equals(name); } public int hashCode() {/* ... */} } // Client code Map<Employee, Calendar> map = new ConcurrentHashMap<Employee, Calendar>(); // ... |
...
Code Block | ||
---|---|---|
| ||
// Mutable class Employee class Employee { private String name; private double salary; private final long employeeID; // Unique for each Employee Employee(String name, double salary, long empID) { this.name = name; this.salary = salary; this.employeeID = empID; } // ... including a hashCode implementation @Override public boolean equals(Object o) { if (!(o instanceof Employee)) { return false; } Employee emp = (Employee)o; return emp.employeeID == employeeID; } } // Client code remains same Map<Employee, Calendar> map = new ConcurrentHashMap<Employee, Calendar>(); // ... |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f9d776e8fab92a7e-053c7afb-4135484e-8a5c8c1c-6f7dfb36a52296ed23f1ac0e"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. References#API 06]] | | ]]></ac:plain-text-body></ac:structured-macro> |
...