Dab tsi yog generic interface?
Dab tsi yog generic interface?

Video: Dab tsi yog generic interface?

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

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.

Tsis tas li ntawd, dab tsi yog qhov generic interface hauv Java?

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.

koj siv generics li cas? Nyob rau hauv ib tug nutshell, cov generics pab kom hom (chav kawm thiab interfaces) los ua qhov tsis muaj thaum txiav txim siab cov chav kawm, interfaces thiab cov txheej txheem. Ntau yam zoo li cov qauv kev paub ntau dua siv hauv cov lus tshaj tawm, typeparameters muab txoj hauv kev rau koj rov siv tib codewith sib txawv inputs.

Ib yam li ntawd, dab tsi yog chav kawm dav dav?

Txhais: “A muaj hom yog a genericclass los yog interface uas yog parameterized tshaj hom. Qhov tseem ceeb, muaj hom tso cai rau koj sau ib tug general, chav kawm dav dav (los yog txoj kev) uas ua haujlwm nrog ntau hom, tso cai rau rov siv dua code.

Lub hom phiaj ntawm kev txwv kev cuam tshuam ntawm ib hom parameter yog dab tsi?

Qhov twg clause nyob rau hauv ib tug generic txhais qhia kev txwv ntawm hom uas yog siv raws li kev sib cav rau hom tsis nyob rau hauv ib tug generic hom , method, delegate, or local muaj nuj nqi . Kev txwv tuaj yeem qhia interfaces , base classes, orrequire a generic hom los ua ib tug siv, nqi, orunmanaged hom.

Pom zoo: