← Back to Miscellaneous
Question 212
Throw IllegalArgumentException
Throw IllegalArgumentException
The methodcheckPositive(int n)should throw anIllegalArgumentExceptionwith the message"Must be positive"ifnis zero or negative. The catch block inmainis already written. Complete thethrowstatement insidecheckPositive. ⚠️ AUTO-INPUT MODE: The input stream will automatically contain'-3\n'.
Expected Output:
Must be positive
Topics:
Miscellaneous
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.