Peb puas tuaj yeem ntes tau pov tseg?
Peb puas tuaj yeem ntes tau pov tseg?

Video: Peb puas tuaj yeem ntes tau pov tseg?

Video: Peb puas tuaj yeem ntes tau pov tseg?
Video: KOOS VAJ ( POJ NIAM NTES TAU ) ( Audio official ) 2020-2021 2024, Kaum ib hlis
Anonim

Yog lawm peb tuaj yeem ntes Throwable tab sis raws li kev xyaum zoo tshaj plaws, nws tsis yog qhia rau ntes Throwable . Catching Throwable suav nrog yuam kev ib yam nkaus, peb yuav tsum tsis txhob ntes yuam kev, nws pab txheeb xyuas JVM teeb meem.

Yog li ntawd, koj yuav tsum ntes tau pov tseg?

Tsis txhob Catch Throwable Koj tuaj yeem siv nws hauv ib ntes clause, mas koj yuav tsum yeej tsis ua! Yog koj siv Pov tau hauv a ntes clause, nws yuav tsis xwb ntes tag nrho cov kev zam; nws tseem yuav ntes tag nrho cov yuam kev. Qhov yuam kev raug muab pov tseg los ntawm JVM los qhia txog cov teeb meem loj uas tsis yog npaj los daws los ntawm daim ntawv thov.

Tsis tas li ntawd, nws puas yog ib qho kev xyaum zoo los ntes RuntimeException? Daim pam- ntes txhua yam - Exception lossis Throwable, uas yog qhov phem dua - tsis yog kev xyaum zoo vim tias koj tab tom xav tias koj tuaj yeem rov qab los ntawm txhua tus cwj pwm tshwj xeeb. Ib sab: Yog, ntes Exception kuj yuav ntes RuntimeException , vim Exception yog superclass ntawm RuntimeException.

Yog li ntawd, peb puas tuaj yeem muab pov tseg hauv Java?

Pov tau yog chav kawm super rau txhua hom kev ua yuam kev thiab kev zam hauv java ua . Chav kawm no yog ib tug tswv cuab ntawm java ua . lang pob. Tsuas yog piv txwv ntawm chav kawm no lossis nws cov chav kawm sub pov tseg los ntawm java ua virtual tshuab los yog los ntawm lub pov nqe lus.

Java yog dab tsi?

Cov Pov tau chav kawm yog superclass ntawm txhua qhov yuam kev thiab kev zam hauv lub Java lus. Tsuas yog cov khoom uas yog piv txwv ntawm cov chav kawm no (los yog ib qho ntawm nws cov subclasses) raug pov los ntawm cov Java Lub tshuab virtual lossis tuaj yeem cuam tshuam los ntawm cov Java pov nqe lus.

Pom zoo: