Program to Check Palindrome using while loop
public class Palindrome {

public static void main(String[] args) {

int num = 121, reversedInteger = 0, remainder, originalInteger;

originalInteger = num;

// reversed integer is stored in variable
while( num != 0 )
{
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder;
num  /= 10;
}

// palindrome if orignalInteger and reversedInteger are equal
if (originalInteger == reversedInteger)
System.out.println(originalInteger + " is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome.");
}
}

When you run the program, the yield will be:

121 is a palindrome number.

In this program,

Initially, given number (num's) esteem is put away in another whole number variable, originalInteger. This is on account of, we have to analyze the estimations of turned around number and unique number toward the end.

At that point, a while circle is utilized to circle through num until the point that it is equivalent to 0.

On every cycle, the last digit of num is put away in leftover portion.

At that point, leftover portion is added to reversedInteger to such an extent that it is added to the following spot esteem (increase by 10).

At that point, the last digit is expelled from num after division by 10.

At last, reversedInteger and originalInteger are thought about. On the off chance that equivalent, it is a palindrome number. If not, it isn't.

Here are the execution steps that happens:

Java Program to Check Whether a Character is Alphabet or Not

Program to Check Palindrome using for loop
public class Palindrome {

public static void main(String[] args) {

int num = 11221, reversedInteger = 0, remainder, originalInteger;

originalInteger = num;

// reversed integer is stored in variable
for( ;num != 0; num /= 10 )
{
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder;
}

// palindrome if orignalInteger and reversedInteger are equal
if (originalInteger == reversedInteger)
System.out.println(originalInteger + " is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome.");
}
}

When you run the program, the yield will be:

11221 isn't a palindrome.

In the above program, for circle is utilized rather than a while circle.
On every cycle, num/= 10 is executed and condition num !=0 is checked.

Java Program to Check Leap Year