Eclipse warn about uncaught Error

五迷三道 提交于 2019-12-12 03:36:53

问题


When failing to catch a subclass of Exception, Eclipse will issue a compilation warning (red).

However, when an subclass of Error is uncaught, no warning is issued, making it easy to forget including the throws SomethingError statement.


回答1:


This is the difference between checked (subclasses of Exception excluding RuntimeException) and unchecked exceptions (subclasses of RuntimeException or Error).

  • Oracle note on the subject
  • Stackoverflow: Java: checked vs unchecked exception explaination



回答2:


This is essentially to avoid having to add exception handling code to every trivial line of code that you write. This question explains that really well: Why are Runtime Exceptions "unchecked" in Java?



来源:https://stackoverflow.com/questions/12162572/eclipse-warn-about-uncaught-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!