A palindrome number is a number that remains the same when its digits are reversed. For example : 12321 is a palindrome number . Now we are going to write a java program to identify weather the given number is palindromic or not.

import java.util.Scanner;
class Palindrome{ 
     public static void main(String args[]){ 
       System.out.print("Please Enter Number: ");
       Scanner read = new Scanner(System.in);
       int number = read.nextInt();
       int actualNumber = number;
       int reverseNumber=0,remainder; 
       while(number > 0) 
       { 
         remainder = number % 10; 
         reverseNumber = reverseNumber * 10 + remainder; 
         number = number / 10; 
       } 
       if(reverseNumber == actualNumber) 
         System.out.println(actualNumber+" is a Palindrome Number"); 
       else
         System.out.println(actualNumber+" is not a Palindrome Number"); 
     } 
}

Leave a Reply

Your email address will not be published. Required fields are marked *