title: Java ArrayList add() method in the instance variable section
body: <p>In a Java class where you normally declare/define instance variables, I would like to have an <code>ArrayList</code> as one of the instance variables and initialize it with some elements to start out with. One way of doing this is declare the <code>ArrayList</code> and initialize it in a constructor. However, I am wondering why it is illegal to initialize the value outside the constructor. For example, </p>
  
  <pre><code>public class Test {
      // some instance variables...
  
      private ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
      list.add("asdf");
  
      // methods here...
  }
  </code></pre>
  
  <p>So I get that this is illegal. But why exactly is this illegal? </p>