— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet132/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   128   129   130   131   132   133   134   135   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

 prep code test code
real code
 prep code
We delete each cell location as it gets hit, and then modify the array to 
be smaller. Except arrays can’t change their size, so we have to make a 
new array and copy the remaining cells from the old array into the new 
smaller array.
3
Option three
0
1
2
4
5
locationCells array
BEFORE any cells 
have been hit
The array starts out with a size 
of 3, and we loop through all 3 cells 
(positions in the array) to look for 
a match between the user guess and 
the cell value (4,5, 6).
When cell ‘5’ is hit, we make a new, 
smaller array with only the remain-
ing cell locations, and assign it to the 
original locationCells reference.
6
locationCells array
AFTER cell ‘5’, which 
was at index 1 in the 
array, has been hit
0
1
4
6
Option three would be much better if the array could shrink, so that we wouldn’t have 
to make a new smaller array, copy the remaining values in, and reassign the reference.
prep 
code


get to know the 
Java API 
you are here
4
131
If only I could find an array 
that could shrink when you remove 
something. And one that you didn’t have 
to loop through to check each element, but 
instead you could just ask it if it contains 
what you’re looking for. And it would let you 
get things out of it, without having to know 
exactly which slot the things are in. 
That would be dreamy. But I know it’s 
just a fantasy...



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   128   129   130   131   132   133   134   135   ...   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