Community
Participate
Working Groups
See this simple source: public static void main(String[] argv) { a(); b(1); c(2); } public static void a() { int i = 0; i = Integer.parseInt("12345") + i; // May throw NumberFormatException. } public static void b(int k) { if(k < 0) { throw new NumberFormatException("Bad"); } } public static void c(int k) { if(k < 0) { throw new Exception("Bad"); } } For some reason only method 'c' is flagged for an unhandled Exception. ;JOOP!
NumberFormatException inherits from RuntimeException and thus is unchecked, which means the compiler doesn't need to complain when uncaught. This behavior is described in the Java language specification.