title: Why does changing the returned variable in a finally block not change the return value?
body: <p>I have a simple Java class as shown below:</p>
  
  <pre><code>public class Test {
  
      private String s;
  
      public String foo() {
          try {
              s = "dev";
              return s;
          } 
          finally {
              s = "override variable s";
              System.out.println("Entry in finally Block");  
          }
      }
  
      public static void main(String[] xyz) {
          Test obj = new Test();
          System.out.println(obj.foo());
      }
  }
  </code></pre>
  
  <p>And the output of this code is this:</p>
  
  <pre><code>Entry in finally Block
  dev  
  </code></pre>
  
  <p>Why is <code>s</code> not overridden in the <code>finally</code> block, yet control printed output?     </p>