Store all the words with its occurrence
HashMap < String , Integer > occ = new HashMap < String , Integer > ( seq . size ( ) ) { @ Override public Integer get ( Object key ) { return containsKey ( key ) ? super . get ( key ) : 0 ; } } ; for ( int i = 0 ; i < seq . size ( ) ; i ++ ) occ . put ( seq . get ( i ) , occ . get ( seq . get ( i ) ) + 1 ) ;