Guest User

Untitled

a guest
Sep 11th, 2019
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Employee {
  2. private int age;
  3. private String name;
  4. public Employee(int age, String name) {
  5. this.age = age;
  6. this.name = name;
  7. }
  8. public boolean equals(Object obj) {
  9. if(obj == null) return false; // パラメータがnullの場合はfalseを返すのがequalsメソッドの条件
  10. return this.name == ((Employee)obj).name; // nameだけ同値ならtrueとしている
  11. }
  12. }
RAW Paste Data