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()
Your implementation must like:
public boolean equals2(Object object2) { if(a.equals(object2.a)) { return true; } else return false; }
With this implementation your both methods would work.