NullPointer is a runtime exception. Runtime exceptions are not caught by the compiler, because they only occur during program runtime (the compiler doesn't run the code to make sure it works, it just...