public class StringUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
TEST_VERSION
The version of this test.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
distance(String s,
String t)
Computes the number of characters that are different in
two strings of equal length.
|
static String |
join(String s,
String t,
String sep)
Returns the string formed by concatenating the argument
strings s and t with a separator string between them.
|
static char |
mostFrequentChar(String s)
Returns the character that appears most frequently in the
string s.
|
static String |
shortest(String s,
String t)
Returns the shortest of the two strings s and t.
|
public static final String TEST_VERSION
public static String join(String s, String t, String sep)
Utility2B.join("abc", "xyz", ":")
returns the string "abc:xyz".s - a non-null stringt - a non-null stringsep - a non-null separator stringpublic static String shortest(String s, String t)
shortest("python", "java") returns the string
"java" because the string "java" is shorter
than the string "python".s - a non-null stringt - a non-null stringIllegalArgumentException - if s and t have the same lengthpublic static int distance(String s, String t)
distance("talk", "talk") returns 0
distance("talk", "walk") returns 1
distance("well", "walk") returns 2
distance("pick", "walk") returns 3
distance("zzzz", "walk") returns 4
s - a non-null stringt - a non-null stringpublic static char mostFrequentChar(String s)
s - a string