public class Utility2B extends Object
| 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 boolean |
isPalindrome(String s)
Returns true if a string is a palindrome.
|
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.
|
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 int distance(String s, String t)
Utility2B.distance("talk", "talk") returns 0
Utility2B.distance("talk", "walk") returns 1
Utility2B.distance("well", "walk") returns 2
Utility2B.distance("pick", "walk") returns 3
Utility2B.distance("zzzz", "walk") returns 4
s - a non-null stringt - a non-null stringIllegalArgumentException - if s and t have different lengthspublic static boolean isPalindrome(String s)
"noon" "level" "racecar"
The empty string is considered to be a palindrome.
s - a non-null string