title: Create a Java class With a variable(arrayList) of the same class
body: <p>Hello I would like to create a Class which contains an array with the same class.</p>
  
  <p>I tried with the code specified below, but the array i created has been infinite.</p>
  
  <pre><code>public class State {
  
  private String Valor1;
  private String Valor2;
  private ArrayList arrayStatesAnteriores;
  
  }
  </code></pre>
  
  <p>And i did the set and get with the refactor of netbeans</p>
  
  <p><code>state.setArrayStatesAnteriores(arrayStateAnteriores);</code></p>
  
  <p>But i have the problem of array being infinite. Any idea?</p>