package example9_1; // What does the program print? // e1 h1 h2 h: Infinity h3 h4 e2 // e1 h1 h2 h: ∞ h3 h4 e2 // e1 h1 h2 h3 h4 e2 // e1 h1 h2 import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.text.DecimalFormat; public class FinallyExample { public static void main(String[] args) { new FinallyExample().example(); } private void example() { System.out.print("e1 "); // Abbreviation for "example" InputStream stream = null; try { stream = new FileInputStream(""); helper(); } catch(NumberFormatException ignoredException) { System.out.println("e:nf"); } catch (FileNotFoundException e) { System.out.println("File not found."); } finally { if(null != stream) { try { stream.close(); } catch(IOException e) { System.out.println("Error while trying to close file!"); } } System.out.println("e:f"); } System.out.print("e2 "); } private void helper(){ System.out.print("h1 "); // Abbreviation for "helper" System.out.print("h2 "); System.out.print("h: " +(5/0)+ " "); System.out.print("h3 "); System.out.print("h4 "); } }