This single line can be used in checking if a text is a palindrome.
boolean palindrome = Text.equalsIgnoreCase(new StringBuilder(Text).reverse().toString());
public class Palindrome {
public static void main(String[] args) {
String Text1 = "Tod saw I was dot";
if (isPalindrome(Text1))
System.out.println("String " + Text1 + " is a palindrome");
else
System.out.println("String " + Text1 + " is not a palindrome");
}
public static boolean isPalindrome(String Text) {
boolean palindrome = Text.equalsIgnoreCase(new StringBuilder(Text).reverse().toString());
return palindrome;
}
}