title: HashMap if containsValue infinite loop issue
body: <p>I am trying to create a fixture list for a group of 6 teams using hashmaps and arrays. I have an array of 6 teams. Each team must play each other twice. I am removing each team at random from the original list of teams and adding them to a new list. This new list is added to a hashmap. In order to avoid the same list of fixtures occuring more than once i am trying to check this new list before adding it to the hashmap, if it already exists then i dont add it. here is my code so far:</p>
  
  <pre><code>List&lt;String&gt; testList = new ArrayList&lt;String&gt;();
  List&lt;String&gt; tempList = new ArrayList&lt;String&gt;();
  Random myRandomizer = new Random();
  String random1,random2;
  tempOrder = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  HashMap&lt;Integer, ArrayList&lt;String&gt;&gt; map = new HashMap&lt;Integer, ArrayList&lt;String&gt;&gt;();
  
  testList.add("team1");
  testList.add("team2");
  testList.add("team3");
  testList.add("team4");
  testList.add("team5");
  testList.add("team6");
  
  
  int x = (testList.size()-1) * 2;
  int y = 0;
  
  while(map.size() &lt; 10){
      System.out.println("Match Day " + (y+1));
      //while(tempOrder.size()&lt;10){
      //  System.out.println("Match Day " + (tempOrder.size()+1));
      while(testList.size()&gt;0){
          random1 = testList.get(myRandomizer.nextInt(testList.size()));
          testList.remove(random1);
          tempList.add(random1);
          random2 = testList.get(myRandomizer.nextInt(testList.size()));
          testList.remove(random2);
          tempList.add(random2);
  
          System.out.println( random1 + " V " + random2 + "\n");
      }
  
      //tempOrder.add((ArrayList&lt;String&gt;) tempList);
  
      // add to hashmap
      // check value exists
      // if true add
      // if not dont
      if(!(map.containsValue(tempList))){
  
          y++;
          map.put(y, (ArrayList&lt;String&gt;) tempList);
          for(String s: tempList){
              testList.add(s);
          }
          tempList.clear();
      //tempOrder.clear();
  
      }
  
      else if((map.containsValue(tempList))){
          //System.out.println("issue");
          //tempOrder.clear();
          for(String s: tempList){
              testList.add(s);
          }
          tempList.clear();
  
  
      }
  </code></pre>
  
  <p>I am getting an infinite loop at the moment when i run this code, can someone please help? i think its the right idea but maybe the wrong execution, Is this the correct way to do this?</p>
  
  <p>Thanks in advance</p>