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