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)