import java.util.InputMismatchException; /** Second example program showing exceptions. * This time, an exception will be raised in a constructor * and passed back to me, and I have to handle it here. */ public class Driver { public static void main(String [] args) { // Create an Item object by calling the default constructor, // which will in turn ask the user for input. Item i = new Item(); /* Item i = null; try { i = new Item(); } catch (InputMismatchException e) { System.out.printf("Input error!\n"); System.exit(1); } */ System.out.printf("The item is: %s\n", i.toString()); } }