Hello public class divbyzero { public static void main(String args[]) { int x=10; int y=10/0; System.out.println(y); } } The java compiler dosent even care about the Values u havce assigned.This is taken care of at Run time .So the JVM throws a Runtime exception.
But I thought expressions such as "10/2" are compile-time constants -- the compiler evaluates them directly rather than generating code to compute them. Why would "10/0" be different?
I think it's more like the compiler substitutes the constants into the code so that it won't look up the values anymore during execution. It still evaluates the expression at runtime.