In this program I'm going to have a list of names which will be printed via a system.out.print() method (e.g. system.out.print("Joe, ") after specific actions are taken.
For example, my output would be
Joe, Ben, Ben, Tom, Ben, Joe, Tom, Tom, Joe, Tom
Now I need to find a way using Java to go through the printed list of names and collect the most common one, ideally so it would print something like this after completing the calculation.
The most common name was: Tom
I thought about creating int counters which would increment ++ each time that the name's were printed, but I don't know how to proceed further with this kind of solution. This is probably fairly nooby so I appreciate your time!