I wonder why the IllegalArgumentException
class does not need to be catched or declared, while other exceptions have to (eg java.net.MalformedURLException
).
public void foo() {
throw new IllegalArgumentException("spam");
}
public void bar() throws MalformedURLException { // required
throw new MalformedURLException("ham");
}
I know that Error
s do not have to be declared because they are not intended to be catched.
I'd like to declare a new exception which also does not require to be catched.