5.4 A palindrome is a string that is the same from right-to-left as from left-to-right. For example, the following are palindromes: ABADABA RADAR OTTO MADAMIMADAM EVE For this exercise, we restrict each string to upper-case letters only. (You are asked to remove this restriction in the next exercise.) Test and develop a method that uses recursion to check for palindromes. The only parameter is a string that is to be checked for palindromity. The method specification is /** * Determines whether a given string of upper-case letters is a palindrome. * A palindrome is a string that is the same from right-to-left as from left-to-right. * * @param s - (a reference to) the given string * * @return true - if the string s is a palindrome; otherwise, false. * * @throws NullPointerException - if s is null. * @throws IllegalArgumentException - if s is the empty string. * */ public static boolean isPalindrome (String s) | |
| View Solution | |
| << Back | Next >> |