Koj thauj cov chav kawm hauv Java li cas?
Koj thauj cov chav kawm hauv Java li cas?

Video: Koj thauj cov chav kawm hauv Java li cas?

Video: Koj thauj cov chav kawm hauv Java li cas?
Video: pob txha ntses daig caj pas lawm yuav ua li cas 2024, Kaum ib hlis
Anonim

Cov Java ClassLoader yog ib feem ntawm lub Java Runtime Ib puag ncig uas dynamically loads Cov chav kawm Java mus rau hauv Java Tshuab Virtual. Cov Java khiav lub sij hawm system tsis tas yuav tsum paub txog cov ntaub ntawv thiab cov ntaub ntawv systems vim yog classloaders. Cov chav kawm Java tsis loaded rau hauv lub cim xeeb ib zaug, tab sis thaum xav tau los ntawm ib daim ntawv thov.

Yog li ntawd, koj yuav ua li cas dynamically thauj cov chav kawm hauv Java?

Yog li cas Dynamic class loading , a chav kawm yog loaded programmatically qhia cov ClassLoader rau thauj nws los ntawm API. JVM tsis paub thauj qhov no chav kawm raws li nws tsis tau tshaj tawm hauv cov cai hloov JVM chav kawm loader tau nug thauj nws dynamically los ntawm kev qhia lub npe chav kawm li String.

Ib yam li ntawd, nws puas tuaj yeem thauj cov chav kawm los ntawm ob ClassLoader? A chav kawm yog loaded ib zaug rau hauv JVM. Yog li thaum a chav kawm yog loaded rau hauv JVM, koj muaj ib tug nkag raws li (pob, classname, classloader ). Yog li ntawd tib yam chav kawm tuaj yeem thauj khoom ob zaug los ntawm ob txawv ClassLoader piv txwv.

Ib yam li ntawd ib tug yuav nug, muaj pes tsawg hom ntawm cov chav kawm loaders nyob rau hauv Java?

peb

Dab tsi yog static class loading thiab dynamic class loading hauv Java?

Cov chav kawm Static Loading : Tsim cov khoom thiab piv txwv siv lo lus tseem ceeb tshiab hu ua static class loading . Dynamic Class Loading : thauj cov chav kawm siv Chav kawm . forName () txoj kev. Dynamic class loading ua tiav thaum lub npe chav kawm tsis paub thaum lub sijhawm sau.

Pom zoo: