SHARE
TWEET

Untitled

a guest Sep 11th, 2019 81 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top