public class Main { public static void main(String[ ] args) { int age = 19; if (age < 21) { throw new ArithmeticException("Sorry - We only sell to customers 21 years old and above!"); } else { System.out.println("Order accepted!"); } } } // Output: Exception in thread "main" java.lang.ArithmeticException: Sorry - We only sell to customers 21 years old and above! // at org.example.Main.main(Main.java:12)
Preview:
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