import java.util.InputMismatchException; /** Second example program showing exceptions. * PASSING-BUCK VERSION * 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 = null; try { i = new Item(); } catch (InputMismatchException e) { System.out.printf("Input error! Here is where problem occurred:\n"); e.printStackTrace(); System.exit(1); } System.out.printf("The item is: %s\n", i.toString()); } }