title: Should I instantiate instance variables on declaration or in the constructor?
body: <p>Is there any advantage for either approach?</p>
  
  <p>Example 1:</p>
  
  <pre><code>class A {
      B b = new B();
  }
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>class A {
      B b;
  
      A() {
           b = new B();
      }
  }
  </code></pre>