Palindrome number in java: A palindrome number is a number that is same after reverse. For example 545, 151, 34543, 343, 171, 48984 are the palindrome numbers. It can also be a string like LOL, MADAM, MALAYALAM etc.
public class Palindrome
{
public static void main(String[] args)
{
int box = 121; int box2 = box; //box2 = 121
int total = 0;
int reverse = 0; //1 12
int count = 0;
while(box>0)
{
System.out.println("Hi");
int rem = box%10;
total = total + rem; //1+2+1=4
reverse = (reverse*10) + rem; //0*10+1=1 1*10+2=12 12*10+1=121
box=box/10; //121/10
count++;
}
if(box2==reverse) System.out.println("Palindrome");
System.out.println("Reversed Number is " + reverse); //palindrome
System.out.println("Count of Digits " + count); //loop 3 times
System.out.println("Sum of Digits " + total); //1+2+1=4
}
}
OUTPUT:

