— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet127/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   123   124   125   126   127   128   129   130   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

 
enhanced 
for
The collection of elements that you want to iterate over. 
Imagine that somewhere earlier, the code said:
String[] nameArray = {“Fred”, “Mary”, “Bob”};
With the first iteration, the name variable has the value of 
“Fred”, and with the second iteration, a value of “Mary”, etc.
Note: depending on the 
programming language they’ve 
used in the past, some people 
refer to the enhanced for as 
the “for each” or the “for 
in” loop, because that’s how it 
reads: “for EACH thing IN the 
collection...”
The colon (:) 
means “IN”.


you are here
4
writing 

program
117
In chapter 3 we talked about the sizes of the various primitives, and how you 
can’t shove a big thing directly into a small thing: 
long y = 42;
 
 int x = y; // won’t compile
long is bigger than an int and the compiler can’t be sure where that long has 
been. It might have been out drinking with the other longs, and taking on really 
big values. To force the compiler to jam the value of a bigger primitive variable 
into a smaller one, you can use the cast operator. It looks like this:
long y = 42; // so far so good
 
 int x = (int) y; // x = 42 cool!
Putting in the cast tells the compiler to take the value of y, chop it down to int 
size, and set x equal to whatever is left. If the value of y was bigger than the 
maximum value of x, then what’s left will be a weird (but calculable*) number: 
long y = 40002; 
 
 // 40002 exceeds the 16-bit limit of a short 
 
 

 
 

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   123   124   125   126   127   128   129   130   ...   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