0
I didn't understand the hashtag and equals() method..help me guys
6 Respostas
+ 4
hashtag is not a method from java >> hashcode()
Java.lang.object has two very important methods: public boolean equals(Object obj) and public int hashCode().
equals() method is used to compare equality of two Objects.
equals() must be reflexive, symmetric, transitive and consistent.
consistent :if the objects are not modified, then it must returning the same value
Furthermore, object.equals(null) must always return false.
hashCode() must also be consistent and returns the hashcode value as an Integer.
consistence: if the object is not modified in terms of equals(), it must keep returning the same value
The relation between the two methods is:
Whenever a.equals(b), then a.hashCode() must be same as b.hashCode().
If you override the equals(), then you should override the hashcode() method
and use the same set of fields from the object that you use to implement equals() and hashCode().
look at this
https://dzone.com/articles/working-with-hashcode-and-equals-in-java
https://www.geeksforgeeks.org/equals-hashcode-methods-java/
+ 3
Which language?
+ 3
Its alright, but I think you should edit the question and add the tag so that the people who know the answer can find your question.
0
java
...sry forgot to mention it
0
ok thanks
0
thanks for your help asa22