Effective Java



Download 2,19 Mb.
Pdf ko'rish
bet158/341
Sana11.07.2022
Hajmi2,19 Mb.
#776765
1   ...   154   155   156   157   158   159   160   161   ...   341
Bog'liq
Effective Java



CHAPTER 6
ENUMS AND ANNOTATIONS
174
mistake in the transition table or forget to update it when you modify the 
Phase
or
Phase.Transition
enum type, your program will fail at runtime. The failure may
be an 
ArrayIndexOutOfBoundsException
, a 
NullPointerException
, or (worse)
silent erroneous behavior. And the size of the table is quadratic in the number of
phases, even if the number of non-null entries is smaller.
Again, you can do much better with 
EnumMap
. Because each phase transition
is indexed by a 
pair
of phase enums, you are best off representing the relationship
as a map from one enum (the “from” phase) to a map from the second enum (the
“to” phase) to the result (the phase transition). The two phases associated with a
phase transition are best captured by associating them with the phase transition
enum, which can then be used to initialize the nested 
EnumMap
:

Download 2,19 Mb.

Do'stlaringiz bilan baham:
1   ...   154   155   156   157   158   159   160   161   ...   341




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