public Student(String name, int age, char sex) {
super();
this.name = name;
this.age = age;
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public char getSex() {
return sex;
}
public void setSex(char sex) {
this.sex = sex;
}
public Student() {
super();
// TODO Auto-generated constructor stub
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + age;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + sex;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Student other = (Student) obj;
if (age != other.age)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (sex != other.sex)
return false;
return true;
}
}
public class Nestificationlevel3 {
public static void main(String[] args) {
//第一个班
Map<String, Student> map1 = new HashMap< >();
map1.put("0x0001", new Student("漩涡鸣人",18,'男'));
map1.put("0x0002", new Student("宇智波佐助",20,'男'));
//第二个班
Map<String,Student> map2 = new HashMap<>();
map2.put("0C0001", new Student("宇智波鼬",25,'男'));
map2.put("0C0002", new Student("漩涡玖辛娜",23,'女'));