Last active
August 31, 2019 11:08
-
-
Save takahashi-h5/66398e7cf9d19957408fcf7ebfcd0125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Employee { | |
private int age; | |
private String name; | |
public Employee(int age, String name) { | |
this.age = age; | |
this.name = name; | |
} | |
public boolean equals(Object obj) { | |
if(obj == null) return false; // パラメータがnullの場合はfalseを返すのがequalsメソッドの条件 | |
return this.name == ((Employee)obj).name; // nameだけ同値ならtrueとしている | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment