All language subtitles for 007 Getters_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

In this lesson, you will add getters to the car class.

You might be wondering, everything is working nice and perfect.

Why are we adding getters?

The issue with the syntax is let's just say my intention is to just access the objects as make field.

Well, using this same syntax, I could accidentally update this field to be Toyota when in fact it

should have a string called Nissan.

So having direct access to an object field is not very safe and it's considered very, very bad practice,

which is why we have to make every single field private to the car class.

So private means that the field is private to the class that it was defined in.

It is not visible anywhere else.

So if we go back to Main Java here, we're trying to directly access the make field, but the make field

is not visible.

Each field is private to the class that it was defined in.

It is not visible anywhere else.

The thing is, I still need to print the Nissan object's fields.

So how can I get all of its field values?

So while the fields are private, a getter is a public method.

Whose return type depends on a particular field and it's always going to be called get followed by the

name of your field again, using camel case.

And what it will do is return the field of the current object that calls this method.

Now we'll create another gutter.

This one needs to return a double.

It will be called Get price.

And it will return the price field of the current object that calls this method.

Now notice we don't need to say this make or this the price because there is no conflicting parameter.

Java is smart enough to return the make field of the current object calls this method.

Now we're going to need another getter.

This one will return an integer.

It's going to be called get.

Yea.

And it needs to return the year.

Of whatever object calls this method.

The final gutter we need to declare is one that returns a string.

It will be called Get Color.

And it needs to return the color field of whatever object is currently calling this method.

So now what we have is perfect.

Our fields are safe, sound and private, and each field has a public getter that returns a copy of

its value.

So now we're good to go.

Here because we no longer have direct access to an object as field.

What we can do is call it's getter.

So Nissan get make Nissan get price.

Nissan jet year and Nissan jet color.

We can do the same thing here from the Dodge object.

We can call get make here.

We can call get price get year.

And get color.

Okay, I'm going to add breakpoints inside every getter because it's going to be really hard pressing

the step in to button when we're already inside the print line function.

So we'll put breakpoints here.

So at this point, we've created two new objects of the car class.

Each variable stores a reference to that object.

First we call get make for this object.

This refers to the current object that's calling this method.

And here we return the make field of that object.

The second getter that gets called was get price.

Which is going to return the price field of the current object.

The third getter that gets called is get Yea, which is going to return the year field of the current

object.

And the fourth getter that gets called is get Cutler, which is going to return the color field of the

current object.

If I press next, it prints every single field inside of the Nissan object.

And now once again, we call get make, get price, get yea get color, but we're going to call these

gutters for this object.

And so once again.

This points to the current object that's calling this method.

That object is make is dodge.

That's what's going to get returned.

Here we return the price of the current object.

Here we return the year of the current object.

And here we return the color.

And that's it.

So to recap, you should always use gutters to access your objects as fields.

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