Here you will learn about number palindrome in java.
A number is called palindrome if it is equal to its reverse.
For example 1221 is a palindrome while 1234 is not palindrome.
Below I have shared the java program to check given number is palindrome or not.
Also Read: String Palindrome in Java
Program for Number Palindrome in Java
class Palindrome { public static void main(String...s) { int n,m,rev=0,i; n=Integer.parseInt(s[0]); m=n; while(n!=0) { i=n%10; rev=(rev*10)+i; n/=10; } if(m==rev) System.out.println("\nNumber is palindrome"); else System.out.println("\nNumber is not palindrome"); } }
Output
”Are yaar bina matlab ka lines mat dala karo isse hum logo ko smajhne mein bahut dikkat hota hai” this means that please do not add extra lines in the source code be straight forward and write comments in code !!!