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,536
  • 15
  • 41
  • 55

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
  • 35,919
  • 9
  • 100
  • 137
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,797
  • 8
  • 68
  • 88