//******************************************************************** // ZeroException.java // // Demonstrates a handled exception. //******************************************************************** public class ZeroException { //----------------------------------------------------------------- // Deliberately divides by zero to produce an exception. //----------------------------------------------------------------- public static void main (String[] args) { int numerator = 10; int denominator = 0; try { System.out.println (numerator / denominator); } catch(Exception e) { System.out.println ("This text will be printed."); System.out.println("Exception : "+e.toString()); } } }