Hello
Java Experts - Could you help me understand why the line after the catch block is executed. My understanding is after the exception - the flow goes to the catch block and does not execute beyond unless there is a finally block. Correct my understanding. Thank you -
public class NoExceptionHandling{
public static void main(
String[] args){
int x=2, y=4, z=0;
try{
y=x/z; // division by 0
System.out.println("This line is not executed because of the exception");
}// end try
catch (Exception e){
System.out.println("Exception!");
}//end of catch block
System.out.println("Here we print the value of x/z = " + y); // I expected that this line will not be executed. See the output
}// end main method
}// end of class NoExceptionHandling
-------------------------------------------------------------
C:\ForAni\Java>java NoExceptionHandling
Exception!
Here we print the value of x/z = 4