Head First Java a brain-Friendly Guide Kathy Sierra and Bert Bates


value of the variable, an object reference variable is full of bits representing  a way to get to the object



Download 17,18 Mb.
Pdf ko'rish
bet42/90
Sana22.06.2022
Hajmi17,18 Mb.
#693704
1   ...   38   39   40   41   42   43   44   45   ...   90
Bog'liq
(Head Up) Kathy Sierra Bert Bates - Head First Java, 3rd Edition Early Release-O\'Reilly Media, Inc. (2021)

value
of the variable, an object reference
variable is full of bits representing 
a way to get to the object.
You use the dot operator (.) on a reference variable to say, “use the thing 
before
the dot to get me the thing 
after
the
dot.” For example:
myDog.bark();
means, “use the object referenced by the variable myDog to invoke the bark() method.” When you use the dot
operator on an object reference variable, think of it like pressing a button on the remote control for that object.


An object reference is just another variable value.
Something that goes in a cup.
Only this time, the value is a remote control.
Primitive Variable
byte x = 7;
The bits representing 7 go into the variable. (00000111). 00000111
Reference Variable
Dog myDog = new Dog();
The bits representing a way to get to the Dog object go into the variable.
The Dog object itself does not go into the variable!
NOTE
With primitive variables, the value of the variable 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.


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.
The 3 steps of object declaration, creation and assignment
Declare a reference variable

Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   38   39   40   41   42   43   44   45   ...   90




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