title: Java Most common string element in array List
body: <p>I have read about it on the forums but with many solutions available none of them seemed to work for me, i have an array list that is being filled as the program runs and at the end i want to find which string element occurred the most and simply print out which one it was. I have seen some solutions using maps and comparator but i dont know how to make them work, as they were used more for an array rather than array list and i dont know how to adapt it to mine.</p>
  
  <p>The code I have:</p>
  
  <pre><code>static ArrayList&lt;String&gt; sequence = new ArrayList&lt;String&gt;();
  
  ////////////////////// ARRAY LIST ////////////////////////////////
  
      public static void PrintArray(){
          System.out.println("The Movement sequence is:  " + sequence);
  
      }
  
      public static void FindMostCommon(){
  
      }
  </code></pre>
  
  <p>elements are added in different parts of the code with ; </p>
  
  <pre><code>sequence.add("MoveLeft() ");
  </code></pre>
  
  <p>I need a simple way to find the most common occurring one from that list, preferably using the function i created; FindMostCommon();</p>
  
  <p>Also an explaination of what is going on in the code would be appreciated :)</p>