0

It seems like return is overridden by finally in a catch block. Is that correct?
For example:

public String myMethod() {

    try {
        // Do stuff

    } catch(Exception e) {
        // Handle exception
     return failed;

    } finally {
        // Close sockets
    }

    return success;    
}

If I get an exception in the above code the method still returns success.

deHaar
  • 17,687
  • 10
  • 38
  • 51
mal
  • 3,022
  • 5
  • 32
  • 62
  • 2
    Not unless you return success from the finally. – Andy Turner Sep 05 '18 at 06:33
  • @GhostCat thanks for the snarky comment. I did some prior research, didn't find anything that related. "Does finally always execute in java" is not my question, the second one helps but that didn't show up in my searches. You need a better attitude. – mal Sep 05 '18 at 07:25
  • 1
    @GhostCat Sorry too, it was too early in the morning. It's hard to read intention from text. – mal Sep 05 '18 at 09:36
  • Sure. I am glad you spoke up. I was actually wondering if "bot bot" is really a bot, with a very clever name ;-) – GhostCat Sep 05 '18 at 09:37

0 Answers0