title: Java defining or initializing attributes of a class
body: <p>Is there a difference between <em>defining</em> class attributes and <em>initializing</em> them? Are there cases where you want to do one over the other? </p>
  
  <p><strong>Example:</strong></p>
  
  <p>The following code snippets should point out the difference that I mean. I'm using a primitive and an object there:</p>
  
  <pre><code>import Java.util.Random;
  
  public class Something extends Activity {
      int integer;
      Random random = null;
  
      Something(){
          integer = 0;
          random = new Random();
          ....
  </code></pre>
  
  <p>vs. </p>
  
  <pre><code>import Java.util.Random;
  
  public class Something extends Activity {
      int integer = null;
      Random random;
  
      Something(){
          integer = 0;
          random = new Random();
          ....
  </code></pre>