— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet72/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   68   69   70   71   72   73   74   75   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

 2. boolean boo = x;
 3. int g = 17;
 4. int y = g;
 5. y = y + 10;
 6. short s;
 7. s = y;
 8. byte b = 3;
 9. byte v = b;
 10. short n = 12;
 11. v = n;
 12. byte k = 128;


you are here
4
primitives 
and 
references
53
Make it Stic
k
The eigh
t primitiv
e types a
re:
boolean
char by
te short
int long
float do
uble
And here
’s a mnem
onic for r
emembe
ring them
:
B

C
areful! 
B
ears 
S
houldn’t
I
ngest 
L
arge 
F
urry 
D
ogs
If you ma
ke up yo
ur own, i
t’ll stick e
ven bette
r.
B_ C_ B
_ S_ I_
L_ F_ D
_
Back away from that keyword!
You know you need a name and a type for your variables. 
You already know the primitive types.
But what can you use as names?
The rules are simple. You 
can name a class, method, or variable according to the 
following rules (the real rules are slightly more fl exible, 
but these will keep you safe):
■ 
It must start with a letter, underscore (_), or 
dollar sign ($). You can’t start a name with a 
number.
■ 
After the fi rst character, you can use numbers as 
well. Just don’t start it with a number.

It can be anything you like, subject to those two 
rules, just so long as it isn’t one of Java’s reserved 
words. 
are keywords (and other things) that the compiler recognizes. 
And if you really want to play confuse-a-compiler, then just try 
using a reserved word as a name.
You’ve already seen some reserved words when we looked at 
writing our fi rst main class:

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   68   69   70   71   72   73   74   75   ...   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