All language subtitles for 025 static final Constants_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 constant is a variable that can never change.

A value that isn't supposed to change shouldn't.

Constants are variables that can never change.

In this lesson, you will define a static final constant.

What is a constant, as I just said twice, a value that can never change?

Why do we use constants to ensure values that shouldn't change, don't?

And why are constant static, because they belong to the class, their value doesn't change regardless

of the object.

A field is not static because it has different values for each object.

In other words, each field belongs to a particular object.

A constant is the same across every object, regardless of the object, every employee works for the

same company, so a constant belongs to the class.

So why are constants final, final means you can never update the variable, a constant is a value that

should never change.

So the state of the constant needs to be final.

Inside employed out Java, you'll notice that I'm plainly writing the company name Java Stars, this

is an important value because it affects our code.

Imagine I accidentally change it here, but here I leave it.

This is bad because now everything is inconsistent and I'm vulnerable to getting bugs never play the

right an important value, you might change it by mistake.

Instead, use a constant.

So here, instead of rewriting the same value over and over.

I'm going to create a static final string.

Constant company name Java stars.

This is the naming convention for constants, every letter is uppercase and words are separated by an

underscore.

This information is in your cheat sheet.

But what's important is that now, instead of writing the same value over and over, I can keep referencing

the constant.

And if you ask me, this is a lot cleaner and it's a lot safer.

Should the constant be private, if there's no reason to make it public, then yes.

The constant is final, so I'm not worried about the color accidentally changing it, the color could

try, but it's not possible.

Here, I'll show you.

Java just won't let them see.

So we could leave it as public, but there isn't a reason to make it publicly available outside the

class, so it's good practice.

And honestly, even if you want to expose the value for whatever reason, it's good practice to just

give it a go getter that returns a copy of that value.

You might be wondering why do we need a GETER that returns a copy of the constant value of the constant

is final.

There's no point, it's just good practice.

If you decide not to include a getter and just make the constant public, that's fine, it's honestly

just a matter of opinion.

OK, now we're going to open up the movie star solution.

Looking at the movie class, can you guess what needs to be a constant.

The String Values DVD and Blu ray, what we did here by rewriting DVD and Blu ray over and over is extremely

bad practice.

We were basically playing with fire.

Can you imagine if I misspelled one of them, I would get so many bugs.

So what I'm going to do is make a constant for DVD private static Final String.

Format DVD.

Is equal to DVD.

And a constant for Blu ray.

Format Blu ray is equal to Blu ray.

Now, I can refer to each constant where I need to.

All right, let's recap a constant, the static, because it belongs to the class, it does not belong

to an object, a constant is final because it should never change.

Use a constant to ensure a value that shouldn't change, doesn't.

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