COMP 202 Lecture Notes - Lecture 23: Null Pointer, Exception Handling, Compile Time
COMP 202 verified notes
23/25View all
Document Summary
System. out. println( very bad math ); break; int[] x = {1,2,3}; for(int i=0; i<=x. length; i++) { System. out. println( literally everything else ); try { catch(arithmeticexception e) { catch(exception e) { finally { Now the -1 is printed as the value for x[0] is 1 and (1/(x[i]-2) will be 1/-1 which is : thus, -1 is printed. There is no exception code to catch by the catch block of code when x[0]. Statement is printed as it is in the finally block of code. The loop ends here if you observe the parenthesis. Therefore, only when the for loop ends or there is a break statement, will the last print statement get executed. So now again the for loop goes to the next value for x. now, x[1] has a value of 2 and (1/(x[i]-2) would be 1/(2-2) which is 1/0 which is not defined.