i have question about how to count matched elements in ArrayList in java..
Ex: My ArrayList contain [sport, sport, ball , player, sport]
i need to output like:
word sport frequency 3
word ball frequency 1
word player frequency 1
thanks for advance
Use a Map:
If you want the words to be sorted alphabetically, use
TreeMapinstead ofHashMap.(Of course this would be much easier using a Guava
Multisetas others have suggested)