Exceptions

Purpose #1: Coping with Errors

try {
  f = new FileInputStream("~cs61b/pj2.solution");
  i = f.read();
}
catch (FileNotFoundException e1) {
  System.out.println(e1);
}
catch (IOException e2) {
  f.close();
}

When the "try" code thows an exception, Java immediately jumps to the first "catch" clause that matches the exceptioin. Match means that the actual exception object thrown is the same class as, or a subclass of, the static type listed in the "catch" clause.

Purpose #2: Escaping a Sinking Ship

Unfinished. Unfinished. Unfinished.

results matching ""

    No results matching ""