Java Exception handling using try...catch

https:‮/‬/www.lautturi.com
Java Exception handling using try...catch
/**
 * @author lautturi.com
 * Java example: Exception handling using try...catch
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		try {
			// divided by 0 will trigger an exception
			int divideByZero = 10 / 0;
			System.out.println(divideByZero);
		}

		catch (ArithmeticException e) {
			System.out.println("ArithmeticException => " + e.getMessage());
		}
	}
}

output:

ArithmeticException => / by zero
Created Time:2017-09-05 11:46:15  Author:lautturi