Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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としている
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement