/* From Java: A Beginner's Guide (3rd Edition) by Herbert Schildt. */ public class ExcDemo2 { public static void main (String [] args) { int numer[] = {4, 8, 16, 32, 64, 128}; int denom[] = {2, 0, 4, 4, 0, 8}; for (int i = 0; i < numer.length; i++) { try { System.out.println(numer[i] + "/" + denom[i] + " is " + (numer[i]/denom[i])); } // The exception handling mechanism allows for // the error to be handled gracefully. catch (ArithmeticException e) { System.out.println("Cannot divide by zero"); } } } }