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



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

if
(userInputNumGiraffes < 
0
) { 
System.
out
.println(
"Get your hands the fuck off my giraffes."
); 

else

if
(userInputNumGiraffes == 
0
) { 
System.
out
.println(
"Sorry, you can cannot add 0 giraffes to the zoo."
); 

else

if
(userInputNumGiraffes < 
3
) { 
System.
out
.println(
"Thanks for donating 1-2 giraffes."
); 

else

if
(userInputNumGiraffes < 
10
) { 
System.
out
.println(
"Thanks for donating 3-9 giraffes."
); 

else

System.
out
.println
("How did you have 10+ giraffes?");



}


See what’s happening? We print a different sentence out to the console
based on the number the user typed in.
For example, that last 
if
check that looks for if the value is <10? That only
happens if the value is not negative, is not zero, is not less than 3, but is less
than 10. Read through it top to bottom a few times to logically follow the
logic.
That code looks good right? Pretty? Easy to read?
No, it looks like absolute shit. It’s an eyesore. Hard to read, hard to
understand, and unpleasant to look at. Here’s the good news; you can make
this 1000x easier if you simply say, “
else if
”. HUH??
How is this possible? Here’s why (if you don’t care, it doesn’t really
matter); the curly braces between those chained “
elses
” and “
ifs
” aren’t
doing anything, nor are putting them on different lines.
It functions exactly the same as doing this:

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   18   19   20   21   22   23   24   25   ...   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