All language subtitles for 012 Scope_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

The scope of a variable can be at the level of a class or a function.

So far, you learned about classes and functions, the class contains all of your code and each function

contains a small grouping of your code.

When you make a variable, it can exist at the level of a class or at the level of a function.

So in this lesson, you're going to learn about function, scope and scope.

First thing you'll need to do is create a new class by yourself inside the section for a project, create

a new file name scoped out Java, and make sure the class has a main method.

The scope of a function spans the two curly brackets, a variable inside the function can only exist

in the function scope.

When this line of code runs, Java creates the variable and when the function ends, that variable falls

out of scope, it ceases to exist outside of the function scope.

It's gone.

And so inside, man, I'm going to make it into a variable named Appel's.

And now I'm going to make a function called some function, this function is void.

It's not going to return anything.

And it will take no parameters.

Now I'm going to call some function from within men.

And inside some function, I'm going to try to print the apples variable that I declared inside men.

Running my code.

And obviously, it doesn't compile, you cannot access a variable from outside of its scope, you created

the variable inside main, the variable only exists inside the main scope.

So if you look at the image, I highlighted the scope for you.

It starts at the first curly brace and it ends at the second curly brace.

And you cannot access the variable from outside of the scope where you created it.

Instead, we need to write the variable inside some function.

Now we can recompile and run the code.

And it prince 5:00, no surprise there.

And now try printing the variable for Min.

And the code doesn't compile, as I just said, you cannot access a variable beyond the scope of its

existence, this variable only exists at the scope of some function, and you cannot access it from

the scope of another function.

Now, a variable in a class exists inside the class scope and the scope of a class spends all of its

code.

If you think of scope as going from the first curly bracket to the second curly bracket, it makes sense

that any variable that you declare at the scope of the class is available anywhere inside the class.

In this case, I declare the variable dogs at the level of the class and have a look.

I can access and print it from anywhere inside the class.

OK, now remove the code from earlier.

But leave the some function call, and now we're going to make it a variable dogs at the level of the

class and set it equal to five.

Now, the scope of dogs spans the entire class, so we're going to print it from the main function.

As well as from some function and the only reason we're still getting an error is because we have to

declare the variable a static, since we're calling it from static methods.

Again, don't worry about what static is for now, we're going to dive deeper into it in module two,

just know that every variable and every function at the class level needs to be static.

OK, rewriting our code.

And it prints five on both occasions, the scope of dogs is at the class level, which means we can

access it from anywhere inside the class.

In this lesson, you learned about function, scope and scope, when you make a variable inside a function,

it only exists within the function scope.

And when you make a verbal at the level of the class, you can access it from anywhere inside the class.

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