CJCoding With Joseph
15per day

Throw IllegalArgumentException

The method checkPositive(int n) should throw an IllegalArgumentException with the message "Must be positive" if n is zero or negative. The catch block in main is already written. Complete the throw statement inside checkPositive.

⚠️ AUTO-INPUT MODE: The input stream will automatically contain '-3\n'.

Expected Output:

Must be positive
Topics:
Miscellaneous
📥 Auto-Input:
-3\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.