Effective Java



Download 2,19 Mb.
Pdf ko'rish
bet216/341
Sana11.07.2022
Hajmi2,19 Mb.
#776765
1   ...   212   213   214   215   216   217   218   219   ...   341
Bog'liq
Effective Java



ITEM 52: USE OVERLOADING JUDICIOUSLY
243
difference because all overloadings of 
println
return 
void
, so the method
reference couldn’t possibly be a 
Callable
. This makes perfect sense, but it’s not
the way the overload resolution algorithm works. Perhaps equally surprising is
that the 
submit
method invocation would be legal if the 
println
method weren’t
also overloaded. It is the combination of the overloading of the referenced method
(
println
) and the invoked method (
submit
) that prevents the overload resolution
algorithm from behaving as you’d expect.
Technically speaking, the problem is that 
System.out::println
is an 
inexact
method reference 
[JLS, 15.13.1] and that “certain argument expressions that
contain implicitly typed lambda expressions or inexact method references are
ignored by the applicability tests, because their meaning cannot be determined
until a target type is selected [JLS, 15.12.2].” Don’t worry if you don’t understand
this passage; it is aimed at compiler writers. The key point is that overloading
methods or constructors with different functional interfaces in the same argument
position causes confusion. Therefore, 

Download 2,19 Mb.

Do'stlaringiz bilan baham:
1   ...   212   213   214   215   216   217   218   219   ...   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