Multiple validations with one throw
Java
Medium
5 views
Problem Description
Task: validate (nameLength > 0) and (score between 0..100). Throw IllegalArgumentException if any fails.
Output Format
Return value
Constraints
Return 1 when valid.
Official Solution
static int validate(int nameLen,int score){if(nameLen<=0||score<0||score>100) throw new IllegalArgumentException();return 1;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!