Angelika Langer - Training & Consulting
HOME | COURSES | TALKS | ARTICLES | GENERICS | LAMBDAS | IOSTREAMS | ABOUT | CONTACT | Twitter | Lanyrd | Linkedin
HOME 


  UPCOMING
  PREVIOUS
  MATERIALS
 
GENERICS 
LAMBDAS 
IOSTREAMS 
ABOUT 
CONTACT 
Effective Java - Implementing equals()

Effective Java - Implementing equals()  
ABSTRACT
 
Functions such as equals(), compareTo(), hashCode(), clone(), and finalize() belong to the basic infrastructure that practically every class type must provide.  Yet it is amazing how little agreement there is in the Java community as how to implement them correctly. Java gurus, such as recognized authors and experienced Java developers, are in serious disagreement regarding correct implementation of these methods. 

In this tutorial we look into the semantics and implementation of the equals() method. For illustration of the related difficulties and misconceptions we study a number of implementations of equals() that have been published by recognized authors in their books or by experienced Java developers in commonly available Java source code. We will find that some of the implementations are incorrect, others are correct, and some are debatable and fragile. We aim to explain the different underlying strategies and to evaluate their up- and downsides. Eventually we condense our conclusions to a set of guidelines that help Java programmers to avoid common mistakes and to provide correct and robust implementations of equals().

 
PREREQUISITES

 
Level: intermediate
Duration: 90 min
Prerequisites: Attendants should be familiar with the basic concepts of Java.
Presented at: ACCU Conference 2002 , Oxford, UK, April 2002
OOP Europe 2002 , Amsterdam, Netherlands, June 2002 

 

If you are interested to hear more about this and related topics you might want to check out the following seminar or skim through some further reading:
 
Seminars
 
Effective Java 
4 day seminar 
(open enrollment and on-site)
 
Papers
 
Secrets of equals()
pulished in Java Solutions - A Supplement of C/C++ Users Journal
(April 2002) 
 
Slides
 
ACCU Conference 2002 , Oxford, UK, April 2002

 
  © Copyright 1995-2005 by Angelika Langer.  All Rights Reserved.    URL: < http://www.AngelikaLanger.com/Conferences/Abstracts/Equals.htm  last update: 7 Nov 2005