Question: X1155: Throwing an Exception The method below takes in a String parameter representing a username. It should throw an Exception if the username is less
X1155: Throwing an Exception
The method below takes in a String parameter representing a username. It should throw an Exception if the username is less than 3 characters long. The method correctly throws the exception, but something is still missing. Fix the problem.
public String validateUser(String userName) { if (userName.length() < 3) { throw new Exception("userName is too short"); } return userName; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
