Question: Code in Java Create a class called ExceptionPractice which includes a main method. The program asks user to enter a string. If the string is
Code in Java
Create a class called ExceptionPractice which includes a main method. The program asks user to enter a string. If the string is empty, it throws a EmptyStringException. The program handles the exception by printing an error message. If the string is not empty, the program converts the string to uppercase and prints it.
You also need to write a class called EmptyStringException. It should extend the Exception class. Include two constructors, the default constructor and a one-parameter constructor (where the parameter type should be String).
Include your code for both ExceptionPractice class and EmptyStringException class below.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
