Run ❯
Get your
own Java
server
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
public class Main { static void checkAge(int age) { if (age < 0) { throw new IllegalArgumentException("Age cannot be negative"); } System.out.println("Age: " + age); } public static void main(String[] args) { try { checkAge(-5); } catch (IllegalArgumentException e) { System.out.println("Error: the age cannot be negative."); } } }
Error: the age cannot be negative.