— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet260/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   256   257   258   259   260   261   262   263   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

G.C.
Exercise Solutions


constructors and 
gc
you are here
4
271
Five-Minute Mystery Solution
Tom noticed that the constructor for the V2Radiator class took an 
ArrayList. That meant that every time the V3Radiator constructor was called, 
it passed an ArrayList in its super() call to the V2Radiator constructor. That 
meant that an extra five V2Radiator SimUnits were created. If Tom was right, 
total power use would have been 120, not the 100 that Sarahʼs expected ratios 
predicted.
Since all the Bot classes create SimUnits, writing a constructor for 
the SimUnit class, that printed out a line everytime a SimUnit was created, 
would have quickly highlighted the problem! 



this is a new chapter
273
10

numbers 
and 
statics
Numbers Matter
Make it Stick
Do the Math. 
But there’s more to working with numbers than just doing primitive 
arithmetic. You might want to get the absolute value of a number, or round a number, or find 
the larger of two numbers. You might want your numbers to print with exactly two decimal 
places, or you might want to put commas into your large numbers to make them easier to read. 
And what about working with dates? You might want to print dates in a variety of ways, or even 
manipulate dates to say things like, “add three weeks to today’s date”. And what about parsing 
a String into a number? Or turning a number into a String? You’re in luck. The Java API is full of 
handy number-tweaking methods ready and easy to use. But most of them are 
static
, so we’ll 
start by learning what it means for a variable or method to be static, including constants in 
Java—static final variables.



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   256   257   258   259   260   261   262   263   ...   555




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