I constructed a class with one String field. Then I created two objects and I have to compare them using == operator and .equals() too
String
==
.equals()
the return type of object.equals is already boolean. there's no need to wrap it in a method with branches. so if you want to compare 2 objects simply compare them:
boolean b = objectA.equals(objectB);
b is already either true or false.