Lesson 31 of 34
Exceptions: Errors संभालना
10 min 30 XP
प्रोग्राम चलते समय error (exception) आने पर वह crash हो जाता है। जोखिम वाला कोड try में रखें और error को catch में संभालें। finally हमेशा चलता है।
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.throw से आप खुद exception उठा सकते हैं, जैसे जब किसी method को गलत value मिले।
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Checked exceptions (जैसे IOException) को compile time पर संभालना ज़रूरी है; unchecked (RuntimeException) को नहीं। Interviews को यह अंतर बहुत पसंद है।