public static String maxCommonPrefix(String one,String two){
  final int minLength=Math.min(one.length(),two.length());
  final StringBuilder sb=new StringBuilder(minLength);
  for (int pos=0; pos < minLength; pos++) {
    final char currentChar=one.charAt(pos);
    if (currentChar != two.charAt(pos)) {
      break;
    }
    sb.append(currentChar);
  }
  return sb.toString();
}

public static String maxCommonPrefix ( String one , String two ) { final int minLength = Math . min ( one . length ( ) , two . length ( ) ) ; final StringBuilder sb = new StringBuilder ( minLength ) ; for ( int pos = 0 ; pos < minLength ; pos ++ ) { final char currentChar = one . charAt ( pos ) ; if ( currentChar != two . charAt ( pos ) ) { break ; } sb . append ( currentChar ) ; } return sb . toString ( ) ; }
returns max common prefix of two strings .
