Check Palindrome Number - Java program

Q. Write a program to check the given number is palindrome or not.

Answer:

Palindrome number is number which is remains same, if its digits are reversed. For example, 121

Palindrome.java

class Palindrome
{
        public static void main(String[] args)
        {
                int num = 12121;
                int rem;
                int reverse=0;
                int temp = num;
                while (num > 0)
                {
                        rem = num % 10;
                        reverse = reverse * 10 +rem;
                        num = num /10;
                }
                if (temp==reverse)
                {
                        System.out.println(temp+" is a Palindrome number");
                }
                else
                        System.out.println(temp+"is not a Palindrome number");
        }
}


Output:

palindrome no