Java program to check whether user input is palindrome or not


Program
import java.util.*; public class CheckPalindrome { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("Enter a number to check whether a number is palindrome or not"); int num = s.nextInt(); int rev = 0, rem, n; n = num; while( num != 0 ) { rem = num % 10; rev = rev * 10 + rem; num /= 10; } if (n == rev) System.out.println(n + " is a palindrome number."); else System.out.println(n + " is not a palindrome number."); } }
Input
Output