@ Nonnull public Word < I > longestCommonPrefix ( Word < ? > other ) { int len = length ( ) , otherLen = other . length ( ) ; int maxIdx = ( len < otherLen ) ? len : otherLen ; int i = 0 ; while ( i < maxIdx ) { I sym1 = getSymbol ( i ) ; Object sym2 = other . getSymbol ( i ) ; if ( ! Objects . equals ( sym1 , sym2 ) ) { break ; } i ++ ; } return prefix ( i ) ; }
Determines the longest common prefix of this word and another word .