Question: Complete the isPalindrome method so that it recursively determines if a String is read the same forward or backward. You may NOT add additional methods
Complete the isPalindrome method so that it recursively determines if a String is read the same forward or backward. You may NOT add additional methods or instance variables ("fields&qout;) to the Palindrome class. The comments contain some suggestions about how you can code this solution recursively.
package edu.uns.cse; /** * This class was created to include a method used by students to recursively determine if a String is a palindrome. * */ public class Palindrome { /** * Method that checks if {@code str} is a palindrome.
* A String IS a palindrome if it has a length of 1 or 0 (a really boring case).
* A String IS NOT a palindrom if the first character of the string (str.charAt(0)) is NOT EQUAL to the (str.length() * - 1)-th character.
* A String MIGHT be a palindrome if the first character is equal to the (str.length() - 1)-th character of the String * AND the substring of {@str} that cuts off the first and last characters (str.substring(1, str.length()-1)) is a * palindrom. * * @param str String that we are testing if it is a palindrome. * @return True if str is a palindrome; false otherwise. */ public static boolean isPalindrome(String str) { } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
