java异常(Java exception)

-编译异常,底层往外抛(throws Exception),可以直接使用Exception,因为它包含所有子异常。最外层处理(try catch)。
-运行时异常,虽然编译可以通过,但是最好处理。例子除数为0。直接在最外层捕获处理(try catch),无需自己抛异常,底层会自动抛出。


Conclusion: programmers need to handle exceptions.
Treatment method:
– compile exceptions, throw exceptions from the bottom layer, and you can use exceptions directly because it contains all child exceptions. Try catch.
– run time exception. Although the compilation can pass, it is best handled. Example divisor is 0. Try catch directly in the outermost layer without throwing exceptions. The bottom layer will throw exceptions automatically.