— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet232/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   228   229   230   231   232   233   234   235   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

private Antenna ant;
No actual Antenna object is made on the heap unless 
or until the reference variable is assigned a new 
Antenna object.
private Antenna ant = new Antenna();
int
long
Object with two primitive instance variables. 
Space for the variables lives in the object.
Object with one non-primitive instance variable—
a reference to an Antenna object, but no actual 
Antenna object This is what you get if you 
declare the variable but don’t initialize it with 
an actual Antenna object.
Antenna
ant
public class CellPhone {
private Antenna ant;
}
public class CellPhone {
private Antenna ant = new Antenna();
}
Object with one non-primitive instance variable, 
and the Antenna variable is assigned a new 
Antenna object.
x
y
Antenna
ant
CellPhone object
CellPhone object
Antenna object
CellPhone object


240
 
chapter 9
object 
creation
The miracle of object creation
Now that you know where variables and objects live, we can dive into 
the mysterious world of object creation. Remember the three steps 
of object declaration and assignment: declare a reference variable, 
create an object, and assign the object to the reference.
But until now, step two—where a miracle occurs and the new object 
is “born”—has remained a Big Mystery. Prepare to learn the facts of 
object life. Hope you’re not squeamish.
1
Declare a reference 
variable
Duck reference
myDuck
Duck myDuck =
 new Duck();
Create an object
Review the 3 steps of object 
declaration, creation and assignment:
Duck object

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   228   229   230   231   232   233   234   235   ...   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