by Dinesh Thakur Category: Control Structures

The Java Example to check if a Number is a palindrome or not.  A Number is palindrome if it remains unchanged when it is reversed, for example "151" is a palindrome as its reverse is "151".

Algorithm for Palindrome Number:


step 1:Set s=0

step 2: Read num

step 3: Set b=num

step 4: Repeat through step-7until (num > 0)

step 5: r=num%10

step 6: s=(s*10)+r

step 7: num=num/10

step 8: If b equals to s then print" b is palindrome"

Else print" b is not a palindrome"

step 9: Exit


Here is the Java Example for Palindrome Number:

import java.util.Scanner;

class PalindromeNumber
                public static void main(String args[])
                      int num,d,s,b;
                Scanner sl=new Scanner(;
                System.out.print("Enter A Number : ");
System.out.println(b+ " and "+ s + " are Same So it is Palindrome");
System.out.println(b+ " and " + s + " are Not Same So it is Not Palindrome");

Palindrome Number in Java

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles