Qhov twg Java tau sim nrog ntau tus ntes tau qhia?
Qhov twg Java tau sim nrog ntau tus ntes tau qhia?

Video: Qhov twg Java tau sim nrog ntau tus ntes tau qhia?

Video: Qhov twg Java tau sim nrog ntau tus ntes tau qhia?
Video: Nkauj tawm tshiab _QHov twg los tau _ by Xim vaj & Xeeb vwj & xis nus vaj _ (2020 - 2021 ) 2024, Hlis ntuj nqeg
Anonim

Multicatch thaiv

Los ntawm Java 7up ib a Ntau - ntes block yog qhia siv qhov no, koj tuaj yeem lis ntau dua ib qho kev zam hauv ib qho ntes thaiv.

Tom qab ntawd, tuaj yeem sim muaj ntau tus ntes hauv Java?

Java ntes ntau yam kev zam A sim thaiv tau ua raws li ib los yog ntau tshaj ntes thaiv. Txhua ntes block yuav tsum muaj ib tug tshwj xeeb handler. Yog li, yog tias koj muaj los ua cov haujlwm sib txawv ntawm qhov tshwm sim ntawm qhov sib txawv, siv java ntau- ntes thaiv.

Dab tsi yog multi catch hauv Java? Hauv Java 7 nws ua tau ntes ntau yam txawv txawv nyob rau hauv tib yam ntes thaiv. Qhov no tseem hu ua ntau catch . Daim ntawv ceeb toom yuav ua li cas ob lub npe tshwj xeeb hauv chav kawm thawj ntes thaiv yog cais los ntawm cov yeeb nkab cim |.

Ntawm no, peb puas tuaj yeem muaj ntau yam catches tom qab ib zaug sim?

Yog koj tuaj yeem muaj ntau tus ntes blocks nrog sim nqe lus. Koj pib nrog ntes tshwj xeeb thiab tom qab ntawd hauv qhov thaiv kawg koj tuaj yeem ua tau ntes puag Exception. Tsuas yog ib qho ntawm cov ntes thaiv yuav lis koj qhov kev zam. Koj tau sim thaiv tsis muaj ib ntes thaiv.

Ib qho kev ntes tau puas muaj ntau dua ib chav kawm tshwj xeeb?

tuav Ntau tshaj ib Hom ntawm Kev zam Hauv Java SE 7 thiab tom qab ntawd, ib leeg ntes block tau kov ntau tshaj ib hom ntawm kev zam . A ntes block uas tuav ntau qhov kev zam hom tsim tsis muaj duplication nyob rau hauv cov bytecode generated los ntawm lub compiler; lub bytecode muaj tsis muaj replication ntawm kev zam tus tuav.

Pom zoo: