























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































int a[SIZE]; y = ... x = (1.0/a[y]) + (2.0/a[y+1]) + (3.0/a[y+2]);
if (y >= SIZE) printf(“Array index %d too big\n”, y); else if (a[y] == 0) printf(“First denominator is 0\n”);
if (y+1 >= SIZE) printf(“Array index %d too big\n”, y+1); else if (a[y+1] == 0) printf(“Second denominator is 0\n”);
if (y+2 >= SIZE) printf(“Array index %d too big\n”, y+2); else if (a[y+2] == 0) printf(“Third denominator is 0\n”); :
statements; try { code...; } catch (Exception-type e) { code for dealing with e exception } more-statements;
int x = 0; int y; : try { y = 1/x; : } catch ( ArithmeticException e) { System.out.println(e); ...; y = 0; }
System.out.println(“y is “ + y);
statements; try { code...; } catch ( NullPointerException e) { code for dealing with a NULL pointer exception } catch ( IOException e) { code for dealing with an IO exception } catch ( MyOwnException e) { code for dealing with a user-defined exception } more-statements;