29. How to override equals and hashCode method in java

preview_player
Показать описание
How to override equals and hashCode method in java

Demo Program:

public class Student {
private int marks;
private String name;

public Student(int marks, String name) {
super();
}

public static void main(String[] args) {
Student s1 = new Student(10, "abc");
Student s2 =new Student(10, "abc");



HashSet Student hs = new HashSet();
}

@Override
public boolean equals(Object obj) {
Student sobj = (Student)obj;
}

@Override
public int hashCode() {
};


}
Рекомендации по теме
visit shbcf.ru