第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

java Comparator為何是函數(shù)式接口?

java Comparator為何是函數(shù)式接口?

素胚勾勒不出你 2019-05-14 15:16:39
@FunctionalInterfacepublicinterfaceComparator{/***Comparesitstwoargumentsfororder.Returnsanegativeinteger,*zero,orapositiveintegerasthefirstargumentislessthan,equal*to,orgreaterthanthesecond.**Intheforegoingdescription,thenotation*sgn(expression)designatesthemathematical*signumfunction,whichisdefinedtoreturnoneof-1,*0,or1accordingtowhetherthevalueof*expressionisnegative,zeroorpositive.**Theimplementormustensurethatsgn(compare(x,y))==*-sgn(compare(y,x))forallxandy.(This*impliesthatcompare(x,y)mustthrowanexceptionifandonly*ifcompare(y,x)throwsanexception.)**Theimplementormustalsoensurethattherelationistransitive:*((compare(x,y)>0)&&(compare(y,z)>0))implies*compare(x,z)>0.**Finally,theimplementormustensurethatcompare(x,y)==0*impliesthatsgn(compare(x,z))==sgn(compare(y,z))forall*z.**Itisgenerallythecase,butnotstrictlyrequiredthat*(compare(x,y)==0)==(x.equals(y)).Generallyspeaking,*anycomparatorthatviolatesthisconditionshouldclearlyindicate*thisfact.Therecommendedlanguageis"Note:thiscomparator*imposesorderingsthatareinconsistentwithequals."**@paramo1thefirstobjecttobecompared.*@paramo2thesecondobjecttobecompared.*@returnanegativeinteger,zero,orapositiveintegerasthe*firstargumentislessthan,equalto,orgreaterthanthe*second.*@throwsNullPointerExceptionifanargumentisnullandthis*comparatordoesnotpermitnullarguments*@throwsClassCastExceptionifthearguments'typespreventthemfrom*beingcomparedbythiscomparator.*/intcompare(To1,To2);/***Indicateswhethersomeotherobjectis"equalto"this*comparator.Thismethodmustobeythegeneralcontractof*{@linkObject#equals(Object)}.Additionally,thismethodcanreturn*trueonlyifthespecifiedobjectisalsoacomparator*anditimposesthesameorderingasthiscomparator.Thus,*comp1.equals(comp2)impliesthatsgn(comp1.compare(o1,*o2))==sgn(comp2.compare(o1,o2))foreveryobjectreference*o1ando2.**Notethatitisalwayssafenottooverride*Object.equals(Object).However,overridingthismethodmay,*insomecases,improveperformancebyallowingprogramstodetermine*thattwodistinctcomparatorsimposethesameorder.**@paramobjthereferenceobjectwithwhichtocompare.*@returntrueonlyifthespecifiedobjectisalso*acomparatoranditimposesthesameorderingasthis*comparator.*@seeObject#equals(Object)*@seeObject#hashCode()*/booleanequals(Objectobj);接口中明明有兩個(gè)抽象方法,intcompare(To1,To2);和booleanequals(Objectobj);為何還是函數(shù)式接口???
查看完整描述

2 回答

?
繁花如伊

TA貢獻(xiàn)2012條經(jīng)驗(yàn) 獲得超12個(gè)贊

Thismethodmustobeythegeneralcontractof{@linkObject#equals(Object)}.
                            
查看完整回答
反對(duì) 回復(fù) 2019-05-14
?
交互式愛情

TA貢獻(xiàn)1712條經(jīng)驗(yàn) 獲得超3個(gè)贊

public@interfaceFunctionalInterface官方文檔:
Ifaninterfacedeclaresanabstractmethodoverridingoneofthepublicmethodsofjava.lang.Object,thatalsodoesnotcounttowardtheinterface'sabstractmethodcountsinceanyimplementationoftheinterfacewillhaveanimplementationfromjava.lang.Objectorelsewhere.
如果接口聲明了一個(gè)覆蓋java.lang.Object的全局方法之一的抽象方法,那么它不會(huì)計(jì)入接口的抽象方法數(shù)量中,因?yàn)榻涌诘娜魏螌?shí)現(xiàn)都將具有java.lang.Object或其他地方的實(shí)現(xiàn)。
                            
查看完整回答
反對(duì) 回復(fù) 2019-05-14
  • 2 回答
  • 0 關(guān)注
  • 1257 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)