Java Program to Check Original equal to its Reverse or Not

« Previous Program Next Program »

Check Original Equals Reverse or Not

To check whether the original number is equal to its reverse or not in Java programming, you have to ask to the user to enter the number and reverse that number then check that reverse is equal to the original or not, before reversing the number make a variable of the same type and place the value of the original number to that variable to check after reversing the number.

Java Programming Code to Check Original Number Equals Reverse or Not

Following Java Program ask to the user to enter the number, to find its reverse and then check whether the reverse number is equal to its original or not, then display the result on the screen:

/* Java Program Example - Check Original Equals Reverse or Not */
import java.util.Scanner;

public class JavaProgram
    public static void main(String args[])
       int num, orig, rev=0, rem;
       Scanner scan = new Scanner(;
       System.out.print("Enter a Number : ");
       num = scan.nextInt();
           rem = num%10;
           rev = rev*10 + rem;
           num = num/10;
       if(orig == rev)
           System.out.print("Reverse is Equal to Original");
           System.out.print("Reverse is not Equal to Original");

When the above Java Program is compile and executed, it will produce the following output. Above Java Programming Example Output (equal):

Java Program check original number equals reverse

Above Java Programming Example Output (not equal):

check original reverse in java

Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:

Java Online Test

« Previous Program Next Program »

© Copyright 2021. All Rights Reserved.