Write a class called StringUtils
with static methods
that manipulate strings. Here are the definitions of the
static
methods:
/** * @param s the String to reverse * @return the string backwards; e.g., string --> gnirts */ public static String reverseString(String string)
/** * Tests if a string is a palindrome. A palindrome is a word * that is the same fowards and backwards. * Some palindromes: * "kayak" * "A man A plan A canal Panama" * * You should consider upper and lower case letters as the same. * However, you don't need to consider punctuation as special cases, * i.e., "A man. A plan. A canal. Panama." will return false. * * @param s the String to test if it's a palindrome * @return true iff the String is a palindrome * @see http://www.palindromelist.com */ public static boolean isPalindrome(String string)
In a comment, answer Why is it appropriate
for these methods to be static
?
Use methods from the String
or StringBuilder
classes to help you write the
methods.
Your main
method should test these methods. As usual,
save the output from several runs
into palindromes.out
.