This is basically a problem of sorting a HashMap by value ;
Initially ,I stored the occurrence of each digit in HashMap (where key denotes the number and value denotes its occurrence ). As we know each item in a Map is an Entry .
So, create a new List and initialise it with entries of HashMap .
Then use Collections.sort() to sort the entries while using Comparator for comparing the values of two entries while sorting .
I have sorted the list in decreasing order so element at top is the required value .