Searching an array list for most common String
<p>I was wondering how I could search an ArrayList of Strings to find the most commonly occurring 'destination' in an 'Itinerary' object I've created (which contains a list of different destinations.) </p>

<p>So far I have:</p>

<pre><code>public static String commonName(ArrayList&lt;Itinerary&gt; itinerary){

    int count = 0;
    int total = 0;

    ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
    Iterator&lt;String&gt;itr2 = names.iterator();

    while(itr.hasNext()){ 

        Itinerary temp = itr.next();  

        if(temp.iterator().hasNext()){ //if its has destinations

                // Destination object in itinerary object 
                Destination temp2 = temp.iterator().next(); 
                String name = temp2.getDestination().toLowerCase().replace(" ", "");

                if(names.contains(name)){
                    count = count + 1;
                    //do something with counting the occurence of string name here
                }
</code></pre>

<p>I'm having problems making an algorithm to search the array for the most commonly occurring string, or strings if there is a tie; and then displaying the number of the 'Itinerary object' (the parameter value) the string is found in. Any help would be great, thank you!!</p>
