Метод equals()
public class Student
{
private int student_id;
public Student(int student_id)
{
this.student_id = student_id;
}
public static void main(String[] args)
{
Student s1 = new Student(8888);
Student s2 = new Student(8888);
if(s1.equals(s2)){
System.out.println("Они равны!");
}
else{
System.out.println("Они не равны!");
}
}
}Last updated