Java Program to Check a Number is Palindrome or Not
In this example, we are giving a program to check whether a number is palindrome or not.
To check a number is palindrome or not:
# To check a number is palindrome or not
public class Palindrome {
public static void main(String[] args) {
int num = 737, reversedInteger = 0, remainder, originalInteger;
originalInteger = num;
while( num != 0) {
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder;
num /= 10;
}
if(originalInteger == reversedInteger)
System.out.println(originalInteger + " is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome.");
}
}
Output:
737 is a palindrome number.