I am having trouble finding the most and least used String in an ArrayList. The program should go through a file of Strings and count how many multiple strings there are in the list. Then print the least and most used name in the list. The ArrayList Part is finished. It is just finding the most and least common name I am having trouble with. I have no idea how to even start with it. I have tried asking but I got it in HashMap form. I kind of tried to figure it out but this is all I could think of.
for (int i = 0; i< dogs.size(); i++)
if dogs.get(0).getName().equals dogs.get(i).getName();
{
dogs.get(i).getName()++;
}
HashMap?ArrayList; really what this means is that anArrayListwas the wrong choice of data structure in the first place. Sometimes the best route to your destination involves reversing a little and starting again on the right road.