Insert all votes in a hashmap
Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( String str : votes ) { if ( map . keySet ( ) . contains ( str ) ) map . put ( str , map . get ( str ) + 1 ) ; else map . put ( str , 1 ) ; }