title: Void and return in Java - when to use
body: <p>I have some "confusion" about void and return. In general, I understand void is used in methods without returning anything, and return is used in methods when I want to return something to the calling code.</p>
  
  <p><em><strong>But in the following code, I can use both, and my question is, which one to use? And how to determine? Is it about performance?</em></strong></p>
  
  <p>Normally, I have the same results in both cases.</p>
  
  <pre><code>public class Calc {
      private double number;
  
      Calc (double n)
      {
          number = n;
      }
  
      public void add(double n)
      {
          number += n;
      }   
  
      public double add1(double n)
      {
          return number = number +  n;
      }
  }
  </code></pre>
  
  <p>Thank you!</p>