title: Set of Arraylists in Java
body: <pre><code>    Set&lt;ArrayList&lt;Integer&gt;&gt; hs = new HashSet&lt;ArrayList&lt;Integer&gt;&gt;();
  
      ArrayList&lt;Integer&gt; arr = new ArrayList&lt;Integer&gt;();
  
      arr.add(1);
      arr.add(2);
      arr.add(3);
      arr.add(4);
  
      hs.add(arr);
  
      ArrayList&lt;Integer&gt; arr1 = new ArrayList&lt;Integer&gt;();
  
      arr1.add(4);
      arr1.add(3);
      arr1.add(2);
      arr1.add(1);
  
      hs.add(arr1);
  
      System.out.println(hs.size());
  </code></pre>
  
  <p>The output I get is 2. I want to get 1 as both the arrayLists have the same elements. How can I achieve this?</p>