title: Why return doesn't exit function in Java?
body: <p>I'm having problem with this function in Java. I don't understand why when <code>lastNodeAttributes==null</code> is true execution jumps to <code>return null;</code> as should, but right after that, instead of returning from function it jumps directly to <code>return fight...;</code> at the very end. Why first return doesn't exit but execution jumps to return in second conditional part?? How is this even possible? Please explain cause obviously I don't understand how basics of java work.</p>
  
  <pre><code>public Node undo() {
      Node lastNode=fight.getLastChild();
      NamedNodeMap lastNodeAttributes = lastNode.getAttributes();
      if(lastNodeAttributes == null) { return null; }
      else { 
          String lastNodeFighter = lastNodeAttributes.getNamedItem("fighter")
                                   .getNodeValue();
          String lastNodePoints = lastNodeAttributes.getNamedItem("points")
                                  .getNodeValue();
          if(Integer.parseInt(lastNodeFighter) == 1) {
              fighter1score-=Integer.parseInt(lastNodePoints);    
          }
          else { fighter2score -= Integer.parseInt(lastNodePoints); }
          return fight.removeChild(fight.getLastChild());
      }
  }
  </code></pre>