title: Java array of ArrayList - strange goings on?
body: <p>I've been pulling my hair out with this all day. Probably a newb error of some sort, but I can't get my head around it.</p>
  
  <p>It started out more complicated, but I've simplified it to:</p>
  
  <pre><code>public class Main {
  
      static ArrayList&lt;Selection&gt;[] a = new ArrayList[2];
  
      public static void main(String[] args) {
  
          // Initialise the Selection ArrayList
  
          for (int i=0; i &lt; a.length; i++) {
              a[i] = new ArrayList&lt;Selection&gt;();
          }
  
          callTest();
  
      }
  
      public static void callTest () {
  
          a[0].add(new Selection(true));
          a[1].add(new Selection(false));
  
          System.out.println(a[0].get(0).getTF());
          System.out.println(a[1].get(0).getTF());
      }
  }
  
  class Selection {
  
      private static boolean trueFalse;
  
      public Selection (boolean iTF) {
          trueFalse = iTF;
      }
  
      public boolean getTF () {
          return trueFalse;
      }
  }
  </code></pre>
  
  <p>Running the program will return:</p>
  
  <pre><code>false
  false
  </code></pre>
  
  <p>instead of the expected (at least to me):</p>
  
  <pre><code>true
  false
  </code></pre>
  
  <p>Can someone please shed some light on this? It appears that whenever the value held in a Selection object is altered, ALL the Selection objects are altered, even though they have a different object reference. Have I done something silly?</p>