Why when I throw a RuntimeException inside of a method I don't get any error but when I throw an IOException inside of a method I need to throw the exception from the method as well?
public void throwException() {
throw new RuntimeException();
}
This works fine. The same thing happens when I throw IndexOutOfBoundsException, NullPointerException and InputMismatchException and so on.
But when I throw IOException, the method has to throw an IOException too:
public void throwException() throws IOException {
throw new IOException();
}