Here is program to find that given number is Palindrome or not.
Output of Above Java Program
Enter the number:
12321
The number is Palindrome Number.
A palindrome number, is the number that can be read the same way in either direction.
import java.io.*; class palindrome { public static void main(String [] args) throws IOException{ try{ BufferedReader obc=new BufferedReader (new InputStreamReader(System.in)); int r,n1,n2; int rev=0; System.out.println("Enter the number: "); n1=Integer.parseInt(obc.readLine()); n2=n1; while(n1>0) { r=n1%10; rev=rev*10+r; n1=n1/10; } if(rev==n2) { System.out.println("The number is Palindrome Number."); } else { System.out.println("The number is not a Palindrome Number."); } } catch(IOException e) { System.out.println("Wrong number entered."); } } }
Output of Above Java Program
Enter the number:
12321
The number is Palindrome Number.