Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Inheritance in Java!
You have completed Inheritance in Java!
Preview
In this video we'll explore what it means for two Objects to be equal
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
There's strict equality, which makes
sure they're literally the same object.
0:00
And then there's looks like equality,
0:01
where as long as the two things have the
same properties, then they are the same.
0:03
Here's an example.
0:07
Let's say we've got a playing card
class with two fields, one for
0:09
the number on the card and
one for the card suit.
0:13
Then let's create two new cards and
make them both a two of clubs.
0:16
By default, Java uses strict equality,
0:21
meaning these two cards are not equal and
would have different hash codes.
0:24
But in some situations,
you might want these to be equal.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up