java - Is RETURN going out the method at any moment, even if it is in a complex IF statement? -


I have such code:

  private last few (SomethingElse unimportant) list list = (List) mListOfSomething.get (SOME_ENUMS); If (list == null) // Do not ask why not list.isEmpty (), I am not the author of this code) list = new ArrayList (); If (transaction.getPartner (for example IAnotherSomething) {IAnotherSomething ias = (IAnotherSomething) transaction.getPartner (); Return ias.getContract (). Next (); } // Important code has been omitted, boolean generates "something" if (some) {// something happens to list.add (contract)} if (! Some) {// something happens to list.add ( Contract)}} return (IContract) List.get (0); } I have a brain - if the list is empty, (or == empty) and if this statement is  (transaction.getPartner () example IAnotherSomething)  True, method if excluded from this statement and  ias.getContract (). Next ()  - or am I wrong about this? 

return statement method eliminates the execution, return the specified value to the caller of the method, whether it Why not within the law. This is not a complicated thing if it's inside "complicated if statement".

In some special cases, the final statement executed in a return statement method will not be:

  1. The return statement is wrapped in an attempt section that contains the last block, Which will be executed before returning by law.

  2. Return Statement evaluates the expression wrapped in an attempt section and throws an exception that is caught by a catch block, which will be executed (and a return statement should be made) Or throw an exception).


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -