java program to check number is palindrome or not code example
Example: palindrome number in java
import java.util.Scanner;
public class Palindrome
{
public static void main(String args[])
{
int num,temp,reverse=0;
Scanner input=new Scanner(System.in);
num=in.nextInt();
temp=num;
//code to reverse the number
while(temp!=0)
{
int d=temp%10; //extracts digit at the end
reverse=reverse*10+d;
temp/=10; //removes the digit at the end
}
// 'reverse' has the reverse version of the actual input, so we check
if(reverse==num)
{
System.out.println("Number is palindrome");
}
else
{
System.out.println("Number is not palindrome");
}
}
}