How Does Exception Terminate Java Program


In this example we will show what happens when an exception occurs.

Source Code

package com.beginner.examples;

public class ExceptionStopExample {
    public static void main(String[] args){
		int i = 0;
		int j = 10/i;
		System.out.println(j);
    }
}

Output:

Exception in thread "main" java.lang.ArithmeticException: / by zero
	at com.beginner.examples.ExceptionStopExample.main(ExceptionStopExample.java:7)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments