import java.util.Scanner; public class MyExceptionTestProgram3 { // Method to get the name from the user public static String getName() throws MissingNameException { String name = new Scanner(System.in).nextLine(); if (name.length() <= 0) throw new MissingNameException(); return name; } // Main method to test out the MissingNameException public static void main(String[] args) { String name = ""; boolean gotValidName = false; while (!gotValidName) { System.out.println("Enter your name"); try { name = getName(); gotValidName = true; } catch (MissingNameException ex) { System.out.println("Error: Name must not be blank"); } } System.out.println("Hello " + name); } }