Dab tsi yog generic interface hauv Java?
Dab tsi yog generic interface hauv Java?

Video: Dab tsi yog generic interface hauv Java?

Video: Dab tsi yog generic interface hauv Java?
Video: Hmong New Song 2019 Xy Lee feat. SuabNag Yaj - Koj Yog Kuv Lub Neej (Official MV - 4K) 2024, Kaum ib hlis
Anonim

Ntau interfaces tau teev cia ib yam li muaj chav kawm. Piv txwv li: Lub MyInterface yog a generic interface uas tshaj tawm txoj kev hu ua myMethod(). Feem ntau, a generic interface tau tshaj tawm nyob rau hauv tib yam li yog a muaj chav kawm. Myclass tsis yog muaj chav kawm.

Kuj paub, dab tsi yog generic interface?

Interfaces uas tau tshaj tawm nrog hom parametersbecome generic interfaces . General interfaces muaj ob lub hom phiaj tib yam li niaj zaus interfaces . Lawv raug tsim los nthuav tawm cov tswv cuab ntawm cov chav kawm uas yuav siv los ntawm lwm cov chav kawm, lossis yuam kom cov chav kawm siv cov haujlwm tshwj xeeb.

Ib sab saum toj, dab tsi yog txoj hauv kev hauv Java? Java Generic Method thiab muaj classesenable programmers los qhia, nrog ib leeg txoj kev tshaj tawm, ib txheej muaj feem xyuam txoj kev , los yog nrog ib qho kev tshaj tawm ib leeg, ib pawg ntawm cov hom muaj feem xyuam, feem. Ntau yam kuj tseem muab compile-time hom kev nyab xeeb uas tso cai rau cov programmers ntes hom tsis raug ntawm lub sijhawm sau.

Tsuas yog li ntawd, qhov interface txhais li cas hauv Java?

Ib interface yog ib hom siv hauv Java . Nws yog zoo ib yam li chav kawm. Nws yog ib qho kev sau ntawm abstract method. Ib chav kawm siv ib qho interface , li noinheriting lub abstract txoj kev ntawm lub interface . Nrog rau cov txheej txheem abstract, ib interface kuj tseem yuav muaj qhov tsis tu ncua, cov txheej txheem ua ntej, cov txheej txheem zoo li qub, thiab hom nested.

Dab tsi yog kev siv generics hauv Java?

Ntau yam tso cai rau ib hom lossis txoj hauv kev ua haujlwm onobjects ntawm ntau hom thaum muab compile-time hom kev nyab xeeb, ua Java ib hom lus statically ntaus ntawv tag nrho. Ntau yam yog ib qho kev tsis sib haum xeeb tshaj plaws Java yam lus.

Pom zoo: