All language subtitles for 006 Workbook 2.5 Solution_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

Before we start, did you try solving the workbook yourself?

If not, please click the link in the resources folder and follow the instructions for this workbook.

This video will present the solution to workbook 2.5 from VES Code.

Make sure to launch the exact folder that contains your Java file in this case, Workbook 2.5 and Task

one tells us to enter in some information.

So first I will say system dot out dot print line asking the user for their first name.

What is your first name?

And once we do that, we're going to say scan next line.

So once this line runs, it's going to wait for the user to enter in a string value.

And after scan, the next line picks up the string value that the user submits we need to store.

The resulting string inside of a variable called.

In this case, first name.

We'll do the same thing for the last name.

What is your last name?

Once the runtime reaches here, we're going to pick up the string value that they submit and we're going

to store that in a variable called last name.

Then we ask them how old they are.

So we'll say, System.out.println.

How old are you?

Scandal.

Next int is going to wait for the user to submit an integer.

And once we pick up the integer that they submit, we're going to store it in a variable called H.

We'll do the same thing for the username and for the username.

We need to ask them to create one.

So we'll say system, not that print line.

Please create a username.

And then we will repeat this process by saying string username is equal to whatever string value gets

returned from skin.

Next line.

Okay, I'm going to stop at the username for now.

Let me just run the code by saying Java C compiling the code inside of sign up dot Java and then running

the compiled code.

So when the code reaches this line, you'd ask them for their first name scanned.

Next line waits for us to enter in a string.

So I'm going to enter in the string, Ryan.

That string is going to get picked up and stored in a variable called first name.

And after asking the user how old they are, next int is going to wait for them to enter an integer,

which they are.

And what just happened.

So after scanned out next and grabbed the integer and stored it inside the variable age.

The next step would have been for the console to print.

Please create a username, which it did, but then scanned out.

Next line.

Should have waited for the user to enter in a username, but it got completely skipped.

Why did that happen?

I warned you about the next line trap in that next line gets completely skipped when placed after a

next int, a next double or a next log and the solution is to place an extra throwaway next line before

the real next line.

But you might be wondering why does this happen?

I do explain why this happens eventually once you reach the delimiter lesson, but for now the simple

solution is to add a throwaway next line and extra next line.

Right before the one that matters.

That way.

The next line that we don't care about gets skipped.

But the next one will, as always, wait for the user to enter a string, which were then going to store

inside of a string variable called username.

So let's see all of this in action.

I'm going to input a name.

Ryan Adams will make them 35.

And beautiful, while the throwaway next line that we don't care about gets completely skipped, it

gets wasted.

The next line that follows wait for the user to enter a string.

I'm going to enter the string are slim 087.

That string is going to get picked up and stored in a variable called username.

All right.

Now feel free to pause the video and complete task one on your own.

That's all for task number one.

Task number two is to print their information.

So the first thing I'm going to say is system, dot, dot, print line.

And instead of just your information, what I'll do is I'll say, here is the information you entered

again, that's up to you.

Not too important what string you print.

But what I want to do is create a line of space between Thank you for joining Java Gram and here is

the information you entered.

And what I can do is use the escape character backslash, which basically tells Java, Hey, look out

for the next character.

It's special.

And by saying n.

Java is going to know to insert a new line right over here.

So let's try it out.

Java Sea.

Sign up to Java running the compiled code.

What is your first name?

Ryan Adams will do this quickly.

35 are slim 087.

Ottawa, Canada.

Notice the extra line of space that was inserted between.

Thank you for joining Java Gram and here is the information that you entered.

Looking back at the final output, a tab of space is inserted before printing each piece of information.

So what we could do is something like this system dot out, dot print line.

On a new line we will print first name.

Um, whatever the variable value ends up being.

First name.

And in order to create a tub of space, I can simply press space four times.

But that's really ugly.

What I can do is use the escape character once again telling Java, Hey, the character that follows

is special, and by putting a T, Java knows, okay, I need to insert a tab of space right here.

I'll give you some time to pause the video so that you can do this for the remaining variables.

Before we start, you should always close scanner.

Otherwise you're going to get a memory leak.

It's always, always good to close scanner when you're done with it.

Otherwise you're wasting resources.

This becomes especially more prevalent when you're building a much bigger application.

For example, if you're ever using scanner in a spring boot web application, you better make sure to

close it.

Otherwise you're going to get a very, very big leak.

All right, let's compile our code and run it.

First name, Ryan.

Last name, Adams.

How old are you?

Will say he's 35.

Are slim.

Zero eight or nine?

Eight six.

Ottawa, Canada.

And this looks great.

Before we wrap up, If you want, feel free to visualize the first part of our code.

Next line picks up the name.

And the string it picks up gets stored in a variable.

Next line picks up the last name and the string it picks up gets stored in a variable next and picks

up the age, which we then store in a variable.

And when next line comes after your next int, next double, next longer and next it gets wasted, it

gets skipped.

But the next line that follows will work business as usual.

You will understand why this trap happens once you reach the lesson on.

Mm.

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