— Scott McNealy, Sun Microsystems Chairman, President and ceo



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

you are here
4
primitives 
and 
references
55
reference
byte short int long 
8 16 32 64 (bit depth not relevant)
An object reference is just
another variable value. 
Something that goes in a cup.
Only this time, the value is a remote control.
With primitive variables, the value of the vari-
able is... the 
value 
(5, -26.7, ʻaʼ).
With reference variables, the value of the 
variable is... 
bits representing a way to get to 
a specific object.
You donʼt know (or care) how any particular 
JVM implements object references. Sure, they 
might be a pointer to a pointer to... but even 
if you 
know
, you still canʼt use the bits for 
anything other than accessing an object.
Dog myDog 
= new Dog();
Tells the JVM to allocate space for a 
reference variable, and names that 
variable myDog. The reference variable 
is, forever, of type Dog. In other words, 
a remote control that has buttons to 
control a Dog, but not a Cat or a Button 
or a Socket. 
1
Declare a reference 
variable
Dog
myDog
Dog myDog =
 new Dog();
Tells the JVM to allocate space for a 
new Dog object on the heap (we’ll 
learn a lot more about that process, 
especially in chapter 9.)
2
Create an object
Dog myDog = new Dog();
The 3 steps of object 
declaration, creation and 
assignment
1
2
3
Dog object
Dog myDog
 
=
 
new Dog();
Assigns the new Dog to the reference 
variable myDog. In other words, 
programs the remote control.
3
Link the object 
and the reference
Dog object
Dog
myDog
We don’t care how many 1’s and 0’s there are in a reference variable.It’s up to each 
JVM and the phase of the moon. 

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   71   72   73   74   75   76   77   78   ...   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