1 package com.tn.hashSet;
 2 
 3 public class Person {
 4     private int id;
 5     private String name;
 6     private String birthday;
 7     public Person(int id, String name, String birthday) {
 8         super();
 9         this.id = id;
10         this.name = name;
11         this.birthday=birthday;
12     }
13     public int getId() {
14         return id;
15     }
16     public void setId(int id) {
17         this.id = id;
18     }
19     public String getName() {
20         return name;
21     }
22     public void setName(String name) {
23         this.name = name;
24     }
25     public String getBirthday() {
26         return birthday;
27     }
28     public void setBirthday(String birthday) {
29         this.birthday = birthday;
30     }
31     @Override
32     public String toString() {
33         return id +"-" + name;
34     }
35     @Override
36     public int hashCode() {
37         final int prime = 31;
38         int result = 1;
39         result = prime * result + id;
40         return result;
41     }
42     @Override
43     public boolean equals(Object obj) {
44         if (this == obj)
45             return true;
46         if (obj == null)
47             return false;
48         if (getClass() != obj.getClass())
49             return false;
50         Person other = (Person) obj;
51         if (id != other.id)
52             return false;
53         return true;
54     }
55 }
Person.java

相关文章:

  • 2021-10-14
  • 2021-06-12
  • 2021-10-15
  • 2021-06-13
  • 2021-10-18
  • 2022-02-05
  • 2022-02-17
  • 2021-09-25
猜你喜欢
  • 2021-08-16
  • 2021-12-17
  • 2021-11-12
  • 2021-09-02
  • 2021-12-02
  • 2022-02-03
  • 2021-06-11
相关资源
相似解决方案