Re: what are the senarios when we should override equals and hashcode

Posted by =?win... on 03. May 2015

On 5/2/2015 8:39 PM, Ajay Paul wrote:




What are the senarios when we should override equals and when we don't have to the same.




You should override them when you need to them to overridden.



:-)



A typical case would be data classes where you need to compare
instances either explicit in your code or implicit by stuffing
them into collections and let the collection code do the comparisons.



Arne


02. May 2015: imported maven project can't be recognized as java in eclipse by Ajay ...

02. May 2015: Re: Good example of EJB interface for CRUD operations by pavel...

01. May 2015: Very urgent requirement || Technical Lead - .Net @ Golden Valley, MN by Vasan...

01. May 2015: Re: If java doesn't support operator overloading, how does String + concatenation work by v_bor...

30. Apr 2015: Re: If java doesn't support operator overloading, how does String + concatenation work by Rober...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Robbi...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Sebas...

30. Apr 2015: Re: What is your favorite WC++IETJ? by ram a...

30. Apr 2015: Re: What is your favorite WC++IETJ? by ram a...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Jerry...

30. Apr 2015: What is your favorite WC++IETJ? by ram a...

30. Apr 2015: Re: If java doesn't support operator overloading, how does String + concatenation work by Eric ...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Eric ...

30. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by j4n b...

30. Apr 2015: If java doesn't support operator overloading, how does String + concatenation work by Ajay ...

29. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by Sebas...

29. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by Sebas...

29. Apr 2015: Re: Survey Request for Research related to Software Engineering and Social Media by Jerry...

29. Apr 2015: Survey Request for Research related to Software Engineering and Social Media by Augus...

29. Apr 2015: Re: Cannot seem to lock HashMap by pww19...

28. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by ram a...

28. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by Jan B...

27. Apr 2015: Re: Good example of EJB interface for CRUD operations by Rober...

27. Apr 2015: Easy exhaustive search with Java 8 Streams by Sebas...

27. Apr 2015: Re: Good example of EJB interface for CRUD operations by pavel...

27. Apr 2015: Good example of EJB interface for CRUD operations by pavel...

25. Apr 2015: Re: enum, what is it good for? by Rober...

24. Apr 2015: Re: enum, what is it good for? by Sebas...

24. Apr 2015: Re: enum, what is it good for? by Rober...

22. Apr 2015: Javascript advance by sheik...

22. Apr 2015: What is Armstrong number? Learn about Armstrong Number by sheik...

22. Apr 2015: Re: FileChooser on 2K Displays by j4n b...

22. Apr 2015: FileChooser on 2K Displays by j4n b...

22. Apr 2015: Re: how to hide and show cursor in JTextField? by Eric ...

22. Apr 2015: Re: how to hide and show cursor in JTextField? by karth...

21. Apr 2015: Re: enum, what is it good for? by Kevin...

21. Apr 2015: Re: runnable jar by Arne ...

21. Apr 2015: Re: C++ hash function -> Java by pww19...

21. Apr 2015: Re: Abuse of AssertionError? by Thoma...

21. Apr 2015: Re: Abuse of AssertionError? by j4n b...

21. Apr 2015: runnable jar by cebi ...

21. Apr 2015: Re: Abuse of AssertionError? by Jerry...

21. Apr 2015: Re: Abuse of AssertionError? by Eric ...

21. Apr 2015: Re: Abuse of AssertionError? by Eric ...

21. Apr 2015: Re: Abuse of AssertionError? by Jerry...

21. Apr 2015: Abuse of AssertionError? by Eric ...

21. Apr 2015: Re: enum, what is it good for? by Marce...

21. Apr 2015: Re: What could be improved about the assert statement by Eric ...

21. Apr 2015: What could be improved about the assert statement by ram a...

21. Apr 2015: Re: enum, what is it good for? by Tassi...

21. Apr 2015: Re: enum, what is it good for? by Leif ...

20. Apr 2015: Re: mouse listener on javafx swing node by Phili...

20. Apr 2015: Re: mouse listener on javafx swing node by Jeff ...

20. Apr 2015: FIGLIO DI PUTTANA NAZIRAZZISTA: PAOLO BARRAI DI CRIMINALI WMO E BSI ITALIA SRL VIA SOCRATE 26 MILANO (OLTRE CHE MEGALAVA CASH MAFIOSO O POLITI-CRIMINALE)! STALKA A MORTE CHI LO FOTOGRAFA E SE "1 INSISTE" IL KILLER PAOLO BARRAI FA "SUICIDARE" DAVVERO! by Memoc...

19. Apr 2015: Re: mouse listener on javafx swing node by Jeff ...

19. Apr 2015: mouse listener on javafx swing node by Phili...

18. Apr 2015: Re: How to extend FilterInputStream to convert tabs to spaces? by Arne ...

16. Apr 2015: Re: QMole Releases Java ECO System for iPhone and iPad by Jerry...

16. Apr 2015: QMole Releases Java ECO System for iPhone and iPad by Chris...

16. Apr 2015: QMole Releases Java ECO System for iPhone and iPad by Chris...

16. Apr 2015: QMole Releases Java ECO System for iPhone and iPad by Chris...

16. Apr 2015: Re: Java/J2EE Project by Robbi...

15. Apr 2015: Re: new JDK 1.8.0_45 by Wayne...

15. Apr 2015: Re: Calling Royal mail Mailmark web service from java by Arne ...

15. Apr 2015: Re: Java/J2EE Project by Arne ...

15. Apr 2015: Re: presentable Java features and programs by Jeff ...

15. Apr 2015: Re: presentable Java features and programs by Jeff ...

14. Apr 2015: What is this? (Java syntax) by ram a...

14. Apr 2015: new JDK 1.8.0_45 by Roedy...

14. Apr 2015: Re: What is this? (Java syntax) by Jeff ...

14. Apr 2015: Re: What is this? (Java syntax) by Jeff ...

14. Apr 2015: Re: What is this? (Java syntax) by Eric ...

14. Apr 2015: Re: What is this? (Java syntax) by Jeff ...

14. Apr 2015: New Requirment Hadoop Developer / Java Developer at Phoenix, AZ by Moin ...

14. Apr 2015: Fix my game? Help! by 12ich...

14. Apr 2015: Re: NotSerializableException by Eric ...

14. Apr 2015: Re: NotSerializableException by Rober...

14. Apr 2015: Java/J2EE Project by rahul...

13. Apr 2015: NotSerializableException by akksh...

13. Apr 2015: Calling Royal mail Mailmark web service from java by loial...

13. Apr 2015: Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? by Marce...

12. Apr 2015: Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? by Marti...

12. Apr 2015: Re: presentable Java features and programs by Arne ...

12. Apr 2015: Re: presentable Java features and programs by Arne ...

12. Apr 2015: Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? by Andre...

12. Apr 2015: Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? by Arne ...

12. Apr 2015: SCHIFOSO PUZZONE NEOPIDUISTA TIZIANO RENZI (WIKI, IL FATTO QUOTIDIANO, ECT) FA DA TRAMITE FRA NAZIMAFIOSO PEDOFILO STRAGISTA SILVIO BERLUSCONI, FASCIO-LESBICA MARINA BERLUSCONI E FIGLIO BERLUS-CO-RROTTISSIMO MATTEO RENZI PER FAR SI CHE BERLUSCONIA... by Memoc...

11. Apr 2015: Re: http://www.w3.org/TR/html5/obsolete.html#non-conforming-features by Arne ...

11. Apr 2015: http://www.w3.org/TR/html5/obsolete.html#non-conforming-features by Al he...

10. Apr 2015: Re: Return of the Applets? by Silvi...

10. Apr 2015: Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? by Marce...

10. Apr 2015: Re: Return of the Applets? by ram a...

10. Apr 2015: Re: how to set LD_LIBRARY_PATH within the Java program? by Andre...

10. Apr 2015: JDBC: scroll cursor "broken" after fetch absolute beyond end? by Andre...

10. Apr 2015: Check out my Toc Java tool, ideal for DevOps! by morti...

09. Apr 2015: Re: how to set LD_LIBRARY_PATH within the Java program? by A Bol...

09. Apr 2015: Re: how to set LD_LIBRARY_PATH within the Java program? by Eric ...

09. Apr 2015: how to set LD_LIBRARY_PATH within the Java program? by John ...

09. Apr 2015: Разработчика систем видеоконференцсвязи. by Таня ...

08. Apr 2015: Re: Return of the Applets? by Kevin...