All language subtitles for 007 hashcode_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

When you had an equals method, you also need to add a hash code method.

I'm going to repeat this one more time, when you add an equals method, you must also add a hash code

and method.

In this lesson, you will learn to write a harsh code method.

First things first inside of your Java Bootcamp resources, open up the folder for this lesson by following

this path.

OK, by default, hash code assigns every object a new integer.

Inside main Java create three new objects of the car class and print their housecoats car, Nissan is

equal to a new car.

Nissan 20 16.

I'll pinotage code.

Print line.

Nissan, Nissan on code.

Copy and paste this twice.

We'll make this one a dodge, change it up where appropriate.

Let's give it a year, twenty, eighteen.

We'll make this one a Toyota.

Now create a copy of the first object and print its housecoat as well, CanI sinta is equal to a copy

of Nissan, Nukaga, Nissan.

And we'll print a tax code as well.

Notice that every single object you create has a different passcode.

That's fine, but what's bad is that objects that are deemed equal have different hash codes.

This is not good.

Equal objects should have the same harsh covid, otherwise you're going to get bugs with hash based

collections like hash map.

Let's see the bug, I'm going to create a hash map, hash map card, double prices.

Is equal to a new object of the Hashmat class that can store card double entries.

And to the Hashmat a minute, every single object except Nisan to.

And the values can be anything, doesn't matter, let's say a price of ten thousand.

So I think we're trying to pass in and end, let's just add a decimal at the end.

OK, 12000.

And 14000.

Now, before I do anything, Nissan, too, and Nissan are equal, you can even test it.

And according to our equals method, they are equal.

So should I expect that printing prices that get Nissan, too, should return the value for the Nissan

Key?

Let's try out.

Silly me, I forgot to print it.

And it returns no, even though Nissan and Nissan, too, are deemed equal.

So why isn't the Hashmat able to retrieve our key?

Hash map sorts keys into buckets.

Hash map uses the hash code to find which bucket the key is in.

And then it can use equals to check for equality.

In our case, it was looking for the object in bucket one eight three seven, whatever else the rest

is.

It couldn't find this bucket, so it returned no.

That's why when you add an equals method, you must always, always add a hash code method that assigns

equal objects the same hash code.

When equal objects have the same harsh code, the Hashmat can easily find the bucket of the key or interested

in.

Luckily, there's a magical method called cash that returns a hash code based on the fields that it

receives and it knows to assign equal object to the same hash code.

So inside Kageyama, we're going to provide our own implementation of hash code, public interest code.

And then a move to return objects, object, hash and add in our fields.

This method is going to essentially use the fields to assign equal objects, the same housecoats and

unequal objects, different housecoats.

You can validate this by commenting the following.

And running the code in main.

And now notice that Nissan and Nissan to have the same code and the unequal objects have different hash

codes.

So now if you try this again, it gets the value for the Nissan Key Perfect's, so why did this work?

Hashmark uses the hash code to find which bucket the key is in.

It was looking for the object and bucket negative six, seven, three, whatever else the rest is.

It found the bucket.

And then it uses equals the check for equality.

So the Take-Home message is, even if your object is equal to one of the Keys, hash map still needs

the hoshko to look for the key.

That's why when we add an equals method, you must also always, always add a hash code method that

matches it.

Let's recap, equal objects must share the same hash code when you add an equals method, you must also

add a hash code method that assigns equal object to the same hash code.

That's because Hashmark uses the hoshko to find which bucket the key in.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.