Java runtime exception yog dab tsi?
Java runtime exception yog dab tsi?

Video: Java runtime exception yog dab tsi?

Video: Java runtime exception yog dab tsi?
Video: Checked vs. Unchecked Exceptions in Java Tutorial - What's The Difference? 2024, Kaum ib hlis
Anonim

Cov Runtime Exception yog niam txiv chav kawm nyob rau hauv tag nrho kev zam ntawm Java programming lus uas xav tias yuav poob lossis tawg qhov kev pab cuam lossis daim ntawv thov thaum lawv tshwm sim. Tsis zoo li kev zam uas tsis suav tias yog Runtime Exceptions , Runtime Exceptions yeej tsis kuaj.

Hauv qhov no, dab tsi yog runtime zam hauv Java nrog piv txwv?

Piv txwv rau RuntimeException yog kev ua haujlwm tsis raug cai cam khwb cia, siv tsis tsim nyog ntawm tus pointer null, referencing ib qho tawm ntawm bounds array element. yuam kev kev zam cov chav kawm qhia txog teeb meem tseem ceeb uas feem ntau tsis tuaj yeem daws los ntawm koj daim ntawv thov. Piv txwv yog tawm ntawm lub cim xeeb yuam kev, pawg overflow, tsis ua hauj lwm ntawm lub Java VM.

Tom qab ntawd, lo lus nug yog, qhov txawv ntawm kev zam thiab kev zam lub sijhawm ua haujlwm yog dab tsi? Ib Kev zam yog kuaj, thiab a RuntimeException yog uncheck. Kos txhais tau hais tias lub compiler xav kom koj lis cov kev zam hauv a ntes, lossis tshaj tawm koj txoj kev pov tseg (los yog ib qho ntawm nws cov superclasses).

Hais txog qhov no, peb puas tuaj yeem ntes runtime zam hauv Java?

Catch Exception yuav ntes ob qho tib si kuaj thiab runtime kev zam . Runtime kev zam sawv cev rau cov teeb meem uas yog qhov tshwm sim ncaj qha ntawm qhov teeb meem programming, thiab xws li yuav tsum tsis txhob raug ntes vim nws ua tau ' tsis tsim nyog xav kom rov qab los ntawm lawv los yog kov lawv. ntes Pov tau yuav ntes txhua yam.

Java exception yog dab tsi?

Kev zam yog cov xwm txheej uas tshwm sim thaum lub sij hawm ua tiav cov kev pab cuam uas cuam tshuam qhov kev khiav hauj lwm ntawm cov lus qhia (piv txwv li faib los ntawm xoom, array nkag tawm ntawm kev khi, thiab lwm yam). Hauv Java , ib kev zam yog ib yam khoom uas qhwv ib qho kev ua yuam kev uas tshwm sim nyob rau hauv ib txoj kev thiab muaj: Cov ntaub ntawv hais txog qhov yuam kev nrog rau nws hom.

Pom zoo: