— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet401/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   397   398   399   400   401   402   403   404   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

serialization 
and
file I/O
you are here
4
435
But what exactly IS an object’s state? 
What needs to be saved?
Now it starts to get interesting. Easy enough to save the primitive 
values 37 and 70. But what if an object has an instance variable 
that’s an object reference? What about an object that has five 
instance variables that are object references? What if those object 
instance variables themselves have instance variables?
Think about it. What part of an object is potentially unique? 
Imagine what needs to be restored in order to get an object that’s 
identical to the one that was saved. It will have a different memory 
location, of course, but we don’t care about that. All we care about 
is that out there on the heap, we’ll get an object that has the same 
state the object had when it was saved.
Engine
eng
Tire []
tires
Tire
[] array obj
ec

Engine object
C
a
r
o
bjec
t
The Car object has two 
instance variables that 
reference two other 
objects.
brainbarbell
Brain Barbell
What has to happen for the Car 
object to be saved in such a way 
that it can be restored back to its 
original state?
Think of what—and how—you 
might need to save the Car.
And what happens if an Engine 
object has a reference to a 
Carburator? And what’s inside the 
Tire [] array object?
What does it take to 
save a Car object?


436
 
chapter 14
When an object is serialized, all the objects 
it refers to from instance variables are 
also 
serialized. And all the objects 
those objects 
refer to are serialized. And all the objects 
those 
objects refer to are serialized... and the best 
Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   397   398   399   400   401   402   403   404   ...   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