Kev zam ua rau nws yooj yim heev rau kev sau cov lej uas qhov kev zam yog pov tseg yuav rhuav tshem cov khoom tsis sib xws thiab tawm hauv cov khoom tsis sib xws. Lawv yeej tseem ceeb yuam kom koj nco ntsoov tias feem ntau txhua nqe lus koj ua tuaj yeem cuam tshuam, thiab ua qhov ntawd kom raug. Ua li ntawd tuaj yeem ua kom yuam kev thiab tawm tsam kev nkag siab.
Vim li cas kev zam tsis zoo C++?
Qhov laj thawj tseem ceeb ntawm C ++ kev zam feem ntau txwv tsis pub yog uas nws nyuaj heev los sau qhov kev zam C ++ code. Kev zam kev nyab xeeb tsis yog ib lo lus uas koj hnov ntau zaus, tab sis qhov tseeb txhais tau tias cov cai uas tsis ntsia nws tus kheej ua phem heev yog tias pawg tsis raug mob.
Is except exception phem?
Koj yuav tsum siv yam tsawg kawg nkaus tsuas zam : kom tsis txhob ntes cov kab ke exceptions zoo li SystemExit lossis KeyboardInterrupt. Nov yog qhov txuas rau docs. Feem ntau koj yuav tsum txhais meej meej exceptions koj xav ntes, kom tsis txhob ntes tsis xav tau exceptions . Koj yuav tsum paub dab tsi exceptions koj tsis quav ntsej.
Vim li cas thiaj raug zam yuav luag txhua lub tswv yim phem?
catch(Exception) yog kev xyaum phem vim nws ntes tag nrho RuntimeException (tsis txheeb xyuas) ib yam nkaus. Qhov no tej zaum yuav yog java tshwj xeeb: Qee zaum koj yuav tau hu rau txoj hauv kev uas cuam tshuam cov kev zam. Yog tias qhov no yog nyob rau hauv koj EJB / kev lag luam logic txheej koj muaj 2 txoj kev xaiv - ntes lawv lossis rov muab pov rau lawv.
Kev zam tsis zoo rau kev ua haujlwm?
Zoo. Tsis sivkev zam vim lawv qhov kev ua tau zoo cuam tshuam yog lub tswv yim tsis zoo. Kev zam pab muab txoj hauv kev zoo los daws cov teeb meem runtime thiab lawv pab sau cov lej huv. Txawm li cas los xij koj yuav tsum taug qab tus lej ntawm kev zam uas tau muab pov rau hauv koj tus lej.