L5.2: Try Catch Exceptions Example #1

PHOTO EMBED

Tue Oct 17 2023 08:46:20 GMT+0000 (Coordinated Universal Time)

Saved by @testpro #java

public class Main {
    public static void main(String[ ] args) {

        int firstNumber = 5;
        int secondNumber = 0;

        int quotient = firstNumber / secondNumber;

        System.out.println(quotient); // error!
    }
}
/* Output:
Exception in thread "main" java.lang.ArithmeticException: / by zero
	at org.example.Main.main(Main.java:8)
*/
content_copyCOPY