5/5 – (1 vote)
Create a class named Palindrome.java then implements the recursive method specified below:
public boolean isPalindrome(String s)
The recursive method: isPalindrome 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. However, when we test if a string is a palindrome, we only consider alphabetic letters(a-z and ignore cases) and digits (0-9), we simply ignore all other symbols. The table below includes various method calls and the value returned:
Method Call Result-isPalindrome(radar) trueisPalindrome(Was It A Rat I Saw?) trueisPalindrome(pe e p) trueisPalindrome(x) trueisPalindrome(12321) trueisPalindrome(Java) false
Reviews
There are no reviews yet.