title: What is the gist of finally block in Java?
body: <p>I think on the following examples; but could not figure out what the importance of the finally block is. Can you tell me the difference of the executions of these two code samples? Also a real life example can be helpful.</p>
  
  <p>Sample 1:</p>
  
  <pre><code>    try{
         // some code 1
      }catch(Exception ex){
         // print exception   
      }finally{
         // some code 2            
      }
  </code></pre>
  
  <p>Sample 2:</p>
  
  <pre><code>    try{
        // some code 1
      }catch(Exception ex){
        // print exception   
      }
      // some code 2
  </code></pre>