Write a method isPalindrome() that takes a String and returns whether it is a palindrome or not.
Question:
Write a method isPalindrome() that takes a String and returns whether it is a palindrome or not.
Write a method longest_palin() that takes a string and returns the longest substring in it that is a palindrome. A brute force method of finding the longest palindromic substring is to loop over all possible substrings and keep track of the longest one encountered. To loop over all substrings, you may use a nested loop with an outer counter i (0 ≤ i < n) and an inner counter j (i < j < n) to generate the substrings st[i:j+1]. Use the isPalindrome() method you wrote.
In the main method, ask the user to enter any sentence. Your program should then display the longest substring in the entered text. Note that all spaces and the case of the letters should be ignored.
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch