Worked example
Dog d1 = new Dog("Rex");
Dog d2 = new Dog("Rex"); // same name, built separately
Dog d3 = d1; // the SAME object
System.out.println(d1 == d2); // false — two different objects
System.out.println(d1 == d3); // true — one object, two names
System.out.println(d1.name.equals(d2.name)); // true — contents match
So == answers «is it literally the same object?». To compare by content, compare the fields yourself — or give the class its own equals method.