17 SUR – HMM – AAFasilkom UI - IKI20100/ IKI80110P Semester Ganjil – 2008/2009 Contoh: equals dan hashCode (1) ‏ Class StudentData{ String studentID, firstName, lastName, address; public boolean equals(Object x){ if (x == null || x.getClass() != getClass())‏ return false; } public int hashCode(){ return Integer.parseInt(studentID); } Class StudentData{ String studentID, firstName, lastName, address; public boolean equals(Object x){ if (x == null || x.getClass() != getClass())‏ return false; } public int hashCode(){ return Integer.parseInt(studentID); }
{}