0

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.

Theodor
  • 5,255
  • 13
  • 39
  • 54

2 Answers2

2

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

Community
  • 1
  • 1
Adam
  • 34,473
  • 9
  • 94
  • 130
1

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?

Community
  • 1
  • 1
Bananeweizen
  • 21,392
  • 8
  • 66
  • 87