Skip to Main Content
Java 6 Illuminated: An Active Learning Approach, 2nd Edition
book

Java 6 Illuminated: An Active Learning Approach, 2nd Edition

by Julie Anderson, Herve J. Franceschi
February 2008
Intermediate to advanced content levelIntermediate to advanced
1288 pages
39h 39m
English
Jones & Bartlett Learning
Content preview from Java 6 Illuminated: An Active Learning Approach, 2nd Edition
Do not use the equality
operators to compare
object data;instead,use
the equals method.
COMMON ERROR
TRAP
5.9 Comparing Objects 247
Figure 5.19
Output from Example
5.11
d1 and d2 are not equal
d1 and d3 are equal
d1 data and d2 data are equal
d1 data and d4 data are not equal
Lines 10 and 11 instantiate two SimpleDate objects with the same data. Line
14 sets the d3 object reference to point to the d1 object. Line 17 instantiates
the d4 object with different data.
In line 20, when we compare d1 and d2 using the equality operator, the
result is false, because the object references d1 and d2 point to two different
objects. However, when we compare d1 and d3 (line ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour
Java Illuminated, 4th Edition

Java Illuminated, 4th Edition

Julie Anderson, Hervé J. Franceschi

Publisher Resources

ISBN: 9780763749637