There are several words in a file. Get the occurrence of every word and sort it based on the occurrence, if more than one word is having same occurrence than sort it alphabetically.
Is there any approach better than HashMap??
HashMap Approach
1) Collect all different words in HashMap
2) If any word repeats increase it's count.
3) Now sort base on count
4) Sort words within same count.