Puas yog sim ntes nres tua Java?
Puas yog sim ntes nres tua Java?

Video: Puas yog sim ntes nres tua Java?

Video: Puas yog sim ntes nres tua Java?
Video: ПРИВОЗ. ОДЕССА СЕГОДНЯ. МЯСО РЫБА ЦЕНЫ И НОЖИ 2022 2024, Hlis ntuj nqeg
Anonim

Lub BadNumberException parameter e nyob rau hauv lub ntes -clause taw qhia rau qhov kev zam pov tseg los ntawm txoj kev faib, yog tias qhov kev zam raug pov tseg. Yog tias tsis muaj kev zam raug muab pov tseg los ntawm ib qho ntawm cov txheej txheem hu ua lossis nqe lus raug tua hauv cov sim -block, ua ntes -block tsuas yog ignored. Nws yuav tsis yog raug tua.

Kuj kom paub yog, puas yog pov ib qho kev zam tsis txhob tua Java?

3 Teb. Yog koj pov tus kev zam , txoj kev kev ua tiav yuav nres thiab cov kev zam yog pov tseg mus rau txoj kev hu. pov ib txwm cuam tshuam cov kev ua tiav ntws ntawm txoj kev tam sim no.

Qhov thib ob, sim ntes thaum kawg ua haujlwm li cas hauv Java? Flow ntawm kev tswj nyob rau hauv sim / ntes / thaum kawg blocks: Yog muaj yog tsis muaj kev zam tshwm sim nyob rau hauv lub code uas yog tam sim no nyob rau hauv sim block ces ua ntej, cov sim block tau ua tiav tag thiab ces tswj tau pauv mus rau thaum kawg block (sib ntes blocks). Yog ib daim ntawv rov qab yog ntsib tog twg los hauv sim los yog ntes thaiv.

Ib sab ntawm no, puas yog code tom qab ntes tau tua Java?

Vim yog ib qho kev zam raug muab pov tseg, Code nyob rau hauv lub kawg clause yuav ua raws li qhov kev zam propagates sab nraud, txawm tias qhov kev zam aborts tus so ntawm txoj kev kev ua tiav ; Code tom qab qhov sim / ntes block yuav tsis tau raug tua tshwj tsis yog qhov kev zam raug ntes los ntawm a ntes block thiab tsis rethrown.

Puas yog Catch yuav tsum tau sim hauv Java?

A ntes clause tsis tuaj yeem nyob tsis muaj ib sim nqe lus. Nws tsis yog yuam kom muaj kawg clauses thaum twg a sim / ntes thaiv tam sim no. Cov sim block tsis tuaj yeem nyob tsis muaj ib qho ntes clause los yog kawg clause. Ib qho code tsis tuaj yeem nyob nruab nrab ntawm qhov sim , ntes , thaum kawg blocks.

Pom zoo: