Check Palindrome Numbers in Java

By | February 29, 2016

Check Palindrome Numbers in Java Programming

Here’s a Simple Program To Check Palindrome Numbers in Java Programming Language. It is important to know about How Modulus Operators work in Java. Also, you must know How A For Loop Works in Java Programming Language.

What is a Palindrome Number?

A Numeral Palindrome or Palindromic Number is an Integer that remains Identical or exactly the same when its digits are Reversed. In other words, the Palindrome Integer is Symmetrical.

Example

101, 222, 545

Also Read: Java Code To Find Armstrong Number

Program To Check Palindrome Numbers in Java Programming

import java.io.*;
import java.util.*;

class PalindromeNumbers
{
    public static void main(String[] arguments)
    {
        int num, rem, sum = 0, temp;
        Scanner sc = new Scanner(System.in);
        System.out.println("\nEnter A Number:");
        num = sc.nextInt();
        for(temp = num; num != 0;)
        {
            rem = num%10;
            sum = (sum*10) + rem;
            num = num/10;
        }
        if(sum == temp)
            System.out.println("\n" + temp + " is a Palindrome Number\n");
        else
            System.out.println("\n" + temp + " is Not a Palindrome Number\n");
    }
}

Output

Check Palindrome Numbers in Java

In case you get any Compilation Errors with this Java Program To Check Palindrome Numbers or you have any doubt about it, mention it in the Comment Section.

Let's Discuss