Java Program for Palindrome Number

Here you will get java program for palindrome number.

A number is said palindrome if its is equal to its reverse. For example, 131 is palindrome while 123 is not.

Below I have shared two ways to check palindrome in java.

Java Program for Palindrome Number

Method 1:

In this method we will reverse the number and then compare it with original number.

Output

Enter a number:
121
Number is Palindrome

 

Method 2:

In this method we will first convert the number into string and then reverse the string. If reversed string is equal to original then number is palindrome otherwise not.

Output

Enter a number:
124
Number is Not Palindrome

Leave a Reply

Your email address will not be published. Required fields are marked *