Preview:
public class ExceptionExample {
    public static void main(String[] args) {
        int n = 26;
        try {
            int m = n / 0;
        } catch (ArithmeticException e) {
            System.out.println("Exception caught: " + e);
        } finally {
            System.out.println("Any number cannot be divided by zero");
        }
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter