either take a new stream or store the words in vector of strings in previous loop
for ( int i = 0 ; i < token . length ; i ++ ) { int count = setOfWords . get ( token [ i ] ) ; if ( count > 1 ) { return token [ i ] ; } } return " NoRepetition " ; }