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



Download 3,91 Mb.
Pdf ko'rish
bet45/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   41   42   43   44   45   46   47   48   ...   70
Bog'liq
Java for Fucking Idiots

null
;
stevesHouse.
color
=
"Blue"
;
You broke it. NullPointerException baby! Whoo!! Application crash ahoy!
java.lang.NullPointerException
There’s a practice in Java called null-checking to avoid this sort of thing.
Basically,
unless you are
absolutely positive 
that your variable is
not null, you’d better check yourself before you Shrek yourself
.
if
(stevesHouse !=
null
) {
stevesHouse.
color
=
"Blue"
;
}
Does it seem contrived? Silly? Unnecessary?


It’s obvious that stevesHouse is null; I just set it to null! Why do a “null
check”?
Programs can become big and scary. Lots of classes, with lots of properties
and methods. Your program might talk to another program. Or
communicate over the internet. Or expect the user to type in some values.
Maybe at some point I’d want to do something like this:
stevesHouse.upstairsFloor.bathroom.sink.faucet =
new
Faucet();
You’d better pray to god that the faucet you want to replace is on the sink,
in the bathroom upstairs, in Steve’s house, and that everything is perfectly
in place, and no one has fucked with the House while you weren’t looking.
Since even one 
NullPointerException
can kill your program, it’s a good
idea to practice defensive coding. That means ensuring your variables have
reasonable values before trying to use them.


CHAPTER 10: METHODS
 
“Do it.” – Senator Palpatine
Methods do things.
Airplanes fly(). CoffeeMakers brew(). People fly like paper, get high like
planes. Cats meow() for no fucking reason when I’m trying to work god
DAMMIT JASPER I JUST FED YOU SHU-.

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   41   42   43   44   45   46   47   48   ...   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