fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Test {
  6. public String x = "Initial Value";
  7.  
  8. public String foo() {
  9. try {
  10. this.x = "Return Value";
  11. return this.x;
  12.  
  13. } catch (Exception e) {
  14. // Do nothing
  15. this.x = "Exception Value";
  16.  
  17. } finally {
  18. this.x = "Finally Value";
  19. }
  20.  
  21. return "Fallback Value";
  22. }
  23.  
  24. public static void main(String[] args) {
  25. Test t = new Test();
  26.  
  27. String x_rtn = t.foo();
  28. System.out.println("t.foo() = " + x_rtn);
  29. System.out.println("t.x = " + t.x );
  30. }
  31. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
t.foo()  = Return Value
t.x      = Finally Value