Consider the program:
class ThrowNull {
void foo() throws Throwable {
throw(Throwable) null;
}
void bar() throws Throwable {
throw null;
}
}
Compiling this yields:
javac ThrowNull.java
ThrowNull.java:8: unreported exception <null>; must be caught or declared to be thrown
throw null;
^
1 error
The literal null is an element of every type, including Throwable. The program
should compile without error; it is legal.
gilad.bracha@eng 2000-04-08
class ThrowNull {
void foo() throws Throwable {
throw(Throwable) null;
}
void bar() throws Throwable {
throw null;
}
}
Compiling this yields:
javac ThrowNull.java
ThrowNull.java:8: unreported exception <null>; must be caught or declared to be thrown
throw null;
^
1 error
The literal null is an element of every type, including Throwable. The program
should compile without error; it is legal.
gilad.bracha@eng 2000-04-08