How to check for palindrome number in java?

Reversing any number means changing the numbers with mirror. For example reverse of 1367 is 7631.

Palindrome number in Java : A palindrome number is a number such that if we reverse it, it will not change. For example some palindrome numbers examples are 121, 212, 12321,-454.

Java code for palindrome number-:

import java.util.Scanner;
public class palindrome_number {
public static void main(String[] args) {
Scanner s=new Scanner(;
System.err.print(“Enter the number : “);
int num=s.nextInt(),n=num,d=0,a;
while(n>0) //Loop which reverses the digits
System.out.println(“Reverse of “+num+” is “+d);
if(num==d) //condition that checks for palindrome number
System.out.println(“Since “+num+” and “+d+” is same so “+num+” is a palindrome number.”);
System.out.println(“Since “+num+” and “+d+” is not same so “+num+” is not a palindrome number.”);

Output -:

Leave a Reply