This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
Lets say you had an array of strings as in your example.
You could create the following class:
You could then create a class with a method that took your string array as a parameter. The method would loop through the array and for every string it would search to see if a MyClass object with that string was present in a hash table. If it wasn't, then it would create a MyClass object as defined above, set the string value to the value of your string and set the elementCount to 1. If a MyClass object was found with an element variable with your string value, then you would increment the elementCount variable of that object by 1.
After the method had gone through the entire array, you could easily find the MyClass object with the highest elementCount value and the corresponding string value in that object.
I hope that makes sense. Theres probably loads of more elegant solutions, but thats one way you could do it.