java - hashCode(): return of an integer after string -
i don't understand in code hashcode()
methode: how can return integer if there string... add string next number doesn't maje string don't understand function equals, object o , o insteadof
public imatriculation(int numeros, string word) { this.numeros = numeros; this.word = word; } public int hashcode() { return this.word.hashcode() + this.numeros; } public boolean equals(object o) { return o instanceof imatriculation && this.word.equals(((imatriculation) o).word) && this.numeros == ((imatriculation) o).numeros; }
as pointed out hashcode returns int not string.
"o" object in java, anything, instanceof used check if object "o" imatriculation before going on , checking details of object.
Comments
Post a Comment