Traverse through map to find the candidate with maximum votes .
int maxValueInMap = 0 ; String winner = " " ; for ( Map . Entry < String , Integer > entry : map . entrySet ( ) ) { String key = entry . getKey ( ) ; Integer val = entry . getValue ( ) ; if ( val > maxValueInMap ) { maxValueInMap = val ; winner = key ; }