title: A Return inside and outside an If Statement
body: <p>This is probably a fairly easy question to answer, but it has been bugging me some time.</p>
  
  <p>If there is a return statement inside an if statement, inside a method (in the Java language), but I add another at the end as a catch-all and to avoid the error, are both return values going to be fired one after the other if the if statement is true?</p>
  
  <p>An example:</p>
  
  <pre><code>public int getNumber() {
   if( 5 &gt; number) {
   return 5;
   }
   return 0;
   }
  </code></pre>
  
  <p>Result: Method returns 5, and then via stacks logic, returns 0 shortly thereafter.</p>
  
  <p>Or, do I need to use an outside variable like so:</p>
  
  <pre><code>int num = 1;
  public int getNumber() {
   if( 5 &gt; number) {
   num = 5;
   }
   return num;
   }
  </code></pre>
  
  <p>Result: Method changes variable num to 5, then  num is returned for use.  I suppose in this case, the return statement wouldn't necessarily be required depending on the variable's usage.</p>
  
  <p>Thanks in advance.</p>