0

Exception

Hi class. InnJava, if I define and array of ints : int arr[] = new int[4]; then I assign using try-catch block arr[8] = 40l/0; what kind of error' Will be generated? ArithmaticException or ArrayIndexOutOfBound exception? Which one Will be checked first by Java JVM?

4th Sep 2023, 8:29 AM
Oliver Pasaribu
2 Antworten
+ 4
Test it in your compiler to see.
4th Sep 2023, 8:33 AM
Chris Coder
Chris Coder - avatar
+ 3
Right side operations always happens first so 40 / 0 will execute first Now you know which exception will come.
4th Sep 2023, 8:58 AM
A͢J
A͢J - avatar