Write a recursive method called
isPalindrome that takes a string as a parameter and that returns true if the
string is a palindrome and false if it is not. A palindrome is a string
like "racecar" that has the same sequence of characters when written
forwards and backwards. Notice that in a palindrome, the first and last
characters match, as do the second and second-to-last, the third and
third-to-last, and so on. The table below includes various method calls and
the value returned:
Method Call Result Method Call Result
----------------------------------------------------------------------
isPalindrome("radar") true isPalindrome("123321") true
isPalindrome("hah") true isPalindrome("peer") false
isPalindrome("peep") true isPalindrome("ab") false
isPalindrome("x") true isPalindrome("a ba") false
isPalindrome("") true isPalindrome("ABba") false
You are restricted to the following String methods:
charAt(index) returns the character at the given index
length() returns the length of the string
substring(fromIndex, toIndex) returns a new string that is a substring of this string from startIndex (inclusive) to stopIndex (exclusive)
For example, if a String s stores the text "hello", then:
s.charAt(0) returns 'h'
s.length() returns 5
s.substring(1, 3) returns "el"
You are not allowed to construct any structured objects (no array,
ArrayList, String, StringBuilder, etc) and you may not use a while loop, for
loop, or do/while loop to solve this problem; you must use recursion.