title: How to save a class instance in an ArrayList that is in the class? It has to be done in the constructor (Java)
body: <p>Given a class like the this:</p>
  
  <pre><code>public class Book {
      private String title;
      private int pages;
      private static ArrayList&lt;Book&gt; ArrayBooks = new ArrayList&lt;Book&gt;();
  
      public Book(String titl, int page){
          title=titl;
          pages=page;
      }
  }
  </code></pre>
  
  <p>How can I keep a reference to every Book in the List, in a way that doesn't require any special calls - ie done automatically by the constructor.</p>
  
  <p>Also, the List should have a max size of 20 books; if the user attempts to create the 21st book, he shouldn't be able to.</p>
  
  <p>Can anyone figure out a way to implement it?</p>