All language subtitles for 023 Polymorphism in Map HashMap vs. TreeMap vs. LinkedHashMap_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
hu Hungarian Download
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

There are collection types that implement the map interface.

For example, a hash map directly implements the map interface.

Linked to hash map as a child class of hash map, which implements the map interface.

Tree map implements these sort map interface, which in turn implements the map interface.

So one way or another, all three classes implement the map interface, whether it's directly or indirectly.

In this lesson, you're in a see polymorphism from the lens of map.

Open the folder for this lesson by following this path in your course resources.

In our map is an interface defines methods that a class must implement.

The hash map class implements this interface, it also implement a bunch of other interfaces, but namely

map.

Here are some of the methods that map the phones.

Once again, the familiar sighs method hash map implements the interface, so we know the hash map class

overrides this method.

You can go back here and call size from the hash map.

Here is another one is empty, and it follows that we can call is empty.

Contains key, and so we know hash map already overrides contains key, which we can use to check for

a particular key.

Anyways, the hash map class implements this interface, so it's basically signing a contract that it's

going to override all of the methods inside the interface.

And it does.

For example, we know our hash map is going to be forced to override or remove books that remove.

And yeah.

So a separate hash map from link to hash map and tree map.

The most striking difference is that hash map has no order length.

Hash map and tree map do follow in order.

If you print the hash map, you'll notice that they appear in a random order.

Tree map entries are sorted according to the compare to method.

Based on the book classes compared to Method, we can expect tree map to sort its entries from lowest

the highest price.

So declare this as a true map instead.

And check it out, all of the entries inside the tree map are sorted from lowest to highest price.

Now for a link to hash map, the entries appear according to their insertion order.

If I declare this as a linked hash map.

And run the app.

The entries appear according to the order that you inserted them in.

So tree map and link to hash map, follow and order hash map doesn't have an order.

Here I can convert this to a key set.

And to an array.

And grabbed the object index to.

And I know it's going to be Game of Thrones.

If I make this into a tree map.

I know in next two is going to return Harry Potter, because that's the way it's going to be sorted.

But if we use a hash map.

I have no idea what in next two is going to give me because everything is going to be out of order.

Random.

So when do you use a map, when there is parity between data?

But specifically, when do we use a hash map?

If you don't care about order, use a hash map because it offers the best performance.

Use a tree map if you need the entries to be sorted, according to what you specify.

Use a linked hash map if you need the entries to be sorted according to their insertion order.

Now, it's worth noting that I always use hash mark because it offers the best performance out of the

three, and it's quite rare that indeed the entries to be sorted.

And in this course, we're probably going to keep using hash map.

Now, it's interesting, as you remember, that interfaces allow for polymorphism, why is polymorphism

important, as always, flexibility.

In this case, print map expects a map.

And our hash map can take the form of a map so we can directly pass it in.

We can even go a step further and declare this as type map.

And even here, I can define this as a trauma.

And what I have to change anything because I know Trump can take the form of map once again.

I can define this as a linked hash map and everything should still work.

So once again, we see that polymorphism helps make our code reusable because all three of our collections

share one common form.

Use a map collection when there is parity between data.

We can drill further and say, use a hash map if you don't care about order because it offers the best

performance.

Use a tree map if you need the entries to be sorted, according to what you specify.

Use a linked hash map if you need the entries to be sorted according to their insertion order.

In this course, we're likely going to keep using hash map because it offers the best performance out

of the three, and it's not common that we're going to need the entries to be sorted.

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