Java for Fucking Idiots: Learn the Basics of Java Programming Without any experience!



Download 3,91 Mb.
Pdf ko'rish
bet21/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   17   18   19   20   21   22   23   24   ...   70
Bog'liq
Java for Fucking Idiots

out
.println(
"Where they at?"
);
}
else
{
System.
out
.println(
"I shall add them at once."
);
}
If the first check (the user inputs a value less than or equal to 0) is 
true
, we
go inside the 
if
block. Otherwise (else!) we go to the 
else
block.
Programming is EASY dude.
Oh, and you don’t need to put the word 
else
on the same line as that curly
brace {.
You could press enter and push the 
else {
to the next line, like this:
if
(userInputNumGiraffes ==
0
) {
System.
out
.println(
"Where they at?"
);
}
else
{
System.
out
.println(
"I shall add them at once."
);
}


You could also put each curly brace on its own line. You’d be committing a
Java code style atrocity, but you can do it if you really want to piss me off.
OK, I hope you’re with me so far; you can check if something is true or
false, then act appropriately using if/else (conditional) logic. This is called
control flow . You’re controlling the flow of the program.
However, there are situations where it’s not simply “do this if X, else do
something different”. You might want to do different things based on how
many giraffes there are, for instance.
How do we do that? Well, there’s a few ways to skin this cat….
Multiple if/else checks
How about something like this? Inside the else block, we add another if/else
check. Inside that else block, we add another if/else check, and so on. That
works, right?
Note that if you’re on a small screen this bit might get messy, but bear with
me…

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   17   18   19   20   21   22   23   24   ...   70




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish