package finally3;

/**
 * Es wird die Fehlerbehandlung mit try/catch und finally demonstriert.
 * @author  Ralf Kunze (rkunze@uos.de), Institut fuer Informatik, Universitaet Osnabrueck
 * @date 20.04.2007
 */
public class ExceptionPuzzle {
	
	public int puzzle1(boolean throwException) {
		try {
			if (throwException)
				return 10/0;		// Division mit 0 => Exception
			else
				return 4711;
		} catch (Exception e) {
			System.err.println("Exception wurde geworfen");
			int i = 10/0;
			return i;
		} finally {
			return 42;
		}
	}
	
}
