title: How to modify private static variable through setter method
body: <p>I have the following variable in a class named Example:</p>
  
  <pre><code>private static int number;
  </code></pre>
  
  <p>If I wanted to assign the variable a number using an outside class, which would I do?</p>
  
  <p>1) Make the setter method in Example static so I can access it like this:  </p>
  
  <pre><code>Example.setNumber(3);
  </code></pre>
  
  <p>2) or Make the setter method non-static so I create an object of Example to set the number</p>
  
  <pre><code>Example e = new Example()
  e.setNumber(3);
  </code></pre>
  
  <p>What are the differences between the two and which one is the better way?</p>