All language subtitles for 004 Overriding toString()_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

A class can override methods that it inherits.

Previously, you saw that the object class is the common ancestor of every class, so every class inherits

methods from the object class.

Now, clients can customize it can override methods that inherits.

So in this lesson, you're going to override the two string method.

Inside main Java, call to string from one of the objects and print the results again, we haven't defined

a two string method inside the person class.

So where is the two string coming from?

Remember that the object class is the ancestor of every single class.

So by default, our person class is going to inherit this two string method.

So let's use it and see what happens.

Run the debugger.

And here it basically returns the identity of the object, the name of the class, followed by an ad

symbol and he hexadecimal representation of the object has code.

So back here, if I press next.

It shows us what we expect the name of the class, followed by the add symbol and the objects code as

a hexadecimal string.

OK, now, instead of printing the hexadecimal, it would be nice if printing the object print its fields'.

That's why we need to override the two string method override means to change the logic of an inherited

method.

You're going to customize you're going to override the two string method for the person class and you

already know how to override a tutoring method.

You've done it a million times before.

All we have to do is replicate the signature of the two string method we're inheriting.

And here we can write whatever we want.

We could return high.

But the point is we overrode the two string method and Java is going to use this one instead.

So try it out, run the debugger.

And it calls the tutoring method that we overrode.

But there's a much easier way to override to string, just right to string and let Intellisense autocomplete

the method for you and beautiful once again, don't worry about super will cover it later.

And now we can just customise the two string method just like we always do.

We'll just return the objects fields as part of a long string.

And now remember, the override annotation just means we're overriding a method that we inherited.

You don't have to include it.

In the past, we never had it.

But it's good practice to leave it because if you misspell the method, it's going to throw an error

and say there's no method string whity to override.

So just leaving it as good practice, it's going to prevent potential errors.

Now, if we rerun the code to the person, object calls the overwritten it to string method.

And it prints our fields.

But recall, we don't need to explicitly call the tutoring method when you print an object java smart

enough to internally call it.

Let's recap, you overrode the two Tshering method.

To override means to change the logic of an inherited method when you override a method, Java calls

that one instead.

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