What issues should be considered when we are overriding equals and hashCode in Java?

0 votes
If we are overriding equals and hashcode, what pitfalls we should consider?
Jun 21, 2018 in Java by Daisy
• 8,050 points
31 views

1 answer to this question.

0 votes
equals() must define an equivalent relation and it must be consistent.

hashcode() must be consistent.
answered Jun 21, 2018 by Sushmita
• 6,880 points

Related Questions In Java

0 votes
2 answers

What is the use of @Override annotation in Java ? When do we use it ?

@Override annotation is used when we override ...READ MORE

answered Aug 14 in Java by Sirajul
• 25,220 points
89 views
0 votes
1 answer

What is the difference == and equals() in Java?

Both the answers (Syntaxes) are correct. If ...READ MORE

answered Jun 5, 2018 in Java by Akrati
• 3,150 points
38 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
317 views
0 votes
1 answer

what are the ways in which a list can be iterated

  There are 5 ways to iterate over ...READ MORE

answered Apr 23, 2018 in Java by sharth
• 3,320 points
47 views
0 votes
1 answer
0 votes
1 answer

Overriding private or static method in Java

You cannot override a private or static ...READ MORE

answered Jul 30, 2018 in Java by code.reaper12
• 3,450 points
80 views
0 votes
1 answer

How can we override back button to act like home button?

Most of the time you need to ...READ MORE

answered Dec 14, 2018 in Java by Daisy
• 8,050 points
72 views
0 votes
1 answer

What is the need to override the equals and hashCode methods in Java?

You must override hashCode() in every class ...READ MORE

answered Jan 2 in Java by Daisy
• 8,050 points
40 views
0 votes
2 answers

When to use LinkedList and ArrayList in Java?

ArrayList is what you want. LinkedList is almost always a ...READ MORE

answered Dec 11, 2018 in Java by Sushmita
• 6,880 points
117 views
0 votes
2 answers

When and how to use Super() keyword in Java?

super() is used to call immediate parent. super() can be ...READ MORE

answered Jul 9, 2018 in Java by Sushmita
• 6,880 points
97 views