+ 1
Overriding equal method
how to override equal method?what are the steps needed?
1 Odpowiedź
+ 1
equals is a method from "Object" the root of every object created (even yours) so you dont need to extend or implement extra things...how to override a function? for equals it would look like this
@Override
public boolean equals(Object o){
// your code
}
be carefull! equals takes a Object so you can put anything inside it, to write a correct equals you have to check if the types of the objects even match and then cast "o" to your desired objecttype .. to refere to your object use "this"