title: How to insert and check a list inside a list of list in Java?
body: <p>I have a scenario where I need to maintain a list of list and do some operation based on it. I am trying to get a list of following kind:</p>
  
  <pre><code>[{peter,se,red},{peter,da,red},{mark,se,red}]
  </code></pre>
  
  <p>where I first create a List to get the values and then insert this list to a list of list if it does not exist already. For instance, if {peter,se,red} comes again, it should not be inserted. Have provided the code snippet below:</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;String&gt;&gt; listOfList = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  ArrayList&lt;String&gt; singleList = new ArrayList&lt;String&gt;();
  
  void someFunction() {
    singleList.add("val1");
    singleList.add("val2");
    singleList.add("val3");
  
   if(listOfList.containsAll(singleList)) {
      &lt;&lt;some operation&gt;&gt;
   } else {
     listOfList.add(singleList);
     &lt;&lt;some operation&gt;&gt;
   }
   //clearing the list, so it can be freshly used 
   //upon successive invocation of the function
   singleList.clear();    
  </code></pre>
  
  <p>Right now, the system just sticks to the else part even when I pass same list twice. Could someone please tell me where I am going wrong. Also, is there another better way to implement this task? </p>