Integer.parseInt("1")
will only be executed at runtime. The compiler doesn't know if the parse operation would even succeed.
Depending on the compiler 1/0
might get optimized at compile time and the compiler might just write the result into the compiled code. Hence it would throw the exception right there. However, if that calculation isn't optimized, the compiler wouldn't know the result of that operation until it is executed.
Btw, my Eclipse compiler doesn't seem to do that (I didn't check the settings yet) and compiles 1/0
just fine.
UPDATE
Although 1/0
would be a constant expression which can be evaluated at compile time, the compiler might still opt to ignore that and compile the code.
Here's some a similar question with some more info: Why doesn't a Java constant divided by zero produce compile time error?