Exception is never thrown in body of corresponding try statement

后端 未结 4 1766
别那么骄傲
别那么骄傲 2020-12-03 05:14

I have a problem with exception handling in Java, here\'s my code. I got compiler error when I try to run this line: throw new MojException(\"Bledne dane\");. T

4条回答
  •  余生分开走
    2020-12-03 05:33

    Any class which extends Exception class will be a user defined Checked exception class where as any class which extends RuntimeException will be Unchecked exception class. as mentioned in User defined exception are checked or unchecked exceptions So, not throwing the checked exception(be it user-defined or built-in exception) gives compile time error.

    Checked exception are the exceptions that are checked at compile time.

    Unchecked exception are the exceptions that are not checked at compiled time

提交回复
热议问题