title: What's the use of finally block in try with resources(Java 7)?
body: <p>The <code>finally</code> block is mainly used to prevent resource leaks which can be achieved in <code>close()</code> method of resource class. What's the use of finally block with <code>try-with-resources</code> statement, e.g: </p>
  
  <pre><code>class MultipleResources {
  
      class Lamb implements AutoCloseable {
          public void close() throws Exception {
              System.out.print("l");
          } 
      }
  
      class Goat implements AutoCloseable {
          public void close() throws Exception {
              System.out.print("g");
          } 
      }
  
      public static void main(String[] args) throws Exception {
          new MultipleResources().run();
      }
  
      public void run() throws Exception {
          try (Lamb l = new Lamb(); Goat g = new Goat();) {
              System.out.print("2");
          } finally {
              System.out.print("f");
          }
      }
  }
  </code></pre>
  
  <p>Ref: K.Seirra, B. Bates OCPJP Book</p>