import java.util.Scanner; import java.lang.StringBuffer; public class palindrome { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); System.out.println("Enter text:"); String usrInput = scnr.nextLine(); System.out.println(); String reverseUsrInput; usrInput = usrInput.replace(" ", ""); reverseUsrInput = new StringBuffer(usrInput).reverse().toString(); if (usrInput.equals(reverseUsrInput)){ System.out.println(usrInput + " is a palindrome"); } else { System.out.println(usrInput + " is not a palindrome"); } scnr.close(); } }