Checked vs unchecked exceptions
Në shqip: Përjashtimet e kontrolluara dhe të pakontrolluara
ShpjegimiSQ
Në Java, përjashtimet „checked“ (si IOException) duhet patjetër t'i kapësh ose t'i deklarosh me throws — kompajleri të detyron. Ato „unchecked“ (RuntimeException, si NullPointerException) zakonisht tregojnë gabime në kod dhe s'je i detyruar t'i kapësh.
EnglishEN
In Java, “checked” exceptions (like IOException) must be caught or declared with throws — the compiler forces you. “Unchecked” ones (RuntimeException, like NullPointerException) usually signal bugs in your code and you're not forced to catch them.
Si ta mendosh
Checked janë si rreziqet e parashikueshme — shiu, prandaj merr çadër. Unchecked janë si të pengohesh në këpucët e tua — duhet të kesh kujdes, s'ka çadër për to.
Lexoje në anglisht
Checked ones are like predictable risks — rain, so you take an umbrella. Unchecked ones are like tripping over your own shoelaces — just be careful, there's no umbrella for that.