I have a School class:
public class School {
    private String name;
    private int id;
    private boolean isOpen;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public boolean isOpen() {
        return isOpen;
    }
    public void setOpen(boolean isOpen) {
        this.isOpen = isOpen;
    }
}
Then I created two instances of School, and compare the equality of the two instances:
public static void main(String[] args) {
        //school1
        School school1 = new School();
        school1.setId(1);
        school1.setName("schoolOne");
        //school2
        School school2 = new School();
        school2.setId(1);
        school2.setName("schoolOne");
            //result is false , why?
        System.out.println("school1 == school2 ? " + school1.equals(school2));
    }
Even though I set the same id and name to school1 & school2 instances, but school1.equals(school2) returns false, why?
 
     
     
     
     
     
     
     
     
     
    