by Dinesh Thakur Category: Data Type

This Reverse Number using Java program prints reverse number using numeric operations i.e. if the input is 564 then output will be 465. we can see after reversing the integer is print the integer digits in reverse order.

Here is the Java Example for the program ReverseNumber :

import java.util.Scanner;

public class ReverseNumber
{
            public static void main(String[] args)
      {
           try
                    {
                System.out.println("Enter a number to Reverse");
                Scanner in = new Scanner(System.in);
                int num = in.nextInt();
                int NumberReverse = 0;
                int remainder = 0;
                    while(num > 0)
                 {
                     remainder = num %10;
                     NumberReverse = NumberReverse * 10 + remainder;
                     num = num /10;
                 }
System.out.println("The Reversed Number is: " + NumberReverse);
           }
catch (Exception e){}
      }
}

Reverse Number using Java

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), 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.



Search Content