All language subtitles for 002 For loops_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

We can use for loops to run code many times.

So far, you learn to store that information using variables, control how your code runs, using a

false and switch and organize your code into functions, every step that you take is a step closer to

becoming a professional Java developer.

And your next step to Java greatness is to control how many times a piece of code needs to run, essentially

by running your code in a loop.

So in this lesson, I'm going to teach you how to use a for loop.

First thing you need to do is create a new Java project named Section five and wow, time really does

fly, doesn't it?

We're already at Section five.

And inside the project, create a new file named for Leubsdorf, Java, and as always, make sure the

class has a main method.

Loops can control how many times a block of code needs to run, and there are two types of loops.

There's the for loop and then there's the wire loop.

As we dive deeper into the section, I want you to keep this in mind.

Use a for loop when you know in advance how many times you need to run a piece of code.

I'm going to repeat this one more time, use a for loop when you know in advance how many times you

need to run a piece of code.

This is really important information that I'm going to put in your cheat sheet, OK, and use a while

loop when it's not clear how many times you need to run a piece of code, because unlike the for loop,

the wire loop doesn't have any fancy counters to keep track of how many times a chunk of code needs

to run.

It's just going to keep running the code as long as some condition remains true.

So we'll start with the for loop.

The Furler can run code a specific number of times, it loops through code for an exact number of times

and then the loop breaks.

Now, the for Loop has three parts.

There is the start, this loop starts running with I equalling one, and then there's this top condition.

This loop is going to keep running as long as I is less than or equal to three.

And then the loop stops.

Then there's the step size I is going to increase by a step size of one every time the loop runs.

Now, this might seem like a lot to digest, but it's going to become easier once we start using for

loops in our code.

So we're going to add this for a loop in Maine, the for loop is going to start running with equaling

one and I equals one.

And it's going to keep running as long as I is less than or equal to three, and every time it runs,

we're going to increase the value by one.

OK, so my stop condition is I is less than or equal to three because I want the code to run three times.

You're going to see exactly how this plays out really soon, but every time this loop runs, we're going

to print the counter I print line I.

I'm going to run the code.

And as I predicted, the code runs three times, the code keeps running as long as it is smaller than

or equal to three and then the loop breaks.

So the counter starts at 1:00, the condition is true, the code runs and after the code runs, AA plus

plus increases the counter by one.

Now we're at the second run and this is going to keep happening as long as I is less than or equal to

three.

Once I isn't smaller than or equal to three anymore, the condition is going to be false and the loop

is going to break.

Now, here's how it looks from a visual perspective, the for loop starts with a counter.

I have one.

So the condition is true and the code runs in after the code runs, I plus plus increases the counter

value by one.

The counter is now two.

And this is just going to keep happening until I is no longer less than or equal to three.

And once that happens, the condition is going to be false and the brakes were essentially designed

iroko to only run three times.

In this lesson, you coded a for loop, and it controls how many times a block of code needs to run.

Philip is useful when you know in advance, when you know exactly how many times you want to run your

code.

We wrote a for loop and we designed it to run exactly three times the for loop starts with equaling

one and the loop keeps running as long as I smaller than or equal to three.

And then the loop breaks.

And now that you know how to use for loops, the world is your oyster.

There are so many apps that you can now build, so strap in and get ready for the workbook bonanza.

It's coming up.

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