Validate age range
Java
Medium
5 views
Problem Description
Task: age must be 1..120. If not, throw IllegalArgumentException.
Output Format
Return value
Constraints
Check both ends.
Official Solution
static int validateAge(int age){if(age<1||age>120) throw new IllegalArgumentException();return age;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!