How to reverse a number using recursion in Java

How to reverse a number using recursion in Java

How to reverse a number using recursion in Java

import java.util.Scanner;
class RecursionReverseDemo
   //A method for reverse
   public static void reverseMethod(int number) {
       if (number < 10) {
       else {
           System.out.print(number % 10);
           //Method is calling itself: recursion
   public static void main(String args[])
	int num=0;
	System.out.println("Input your number and press enter: ");
	Scanner in = new Scanner(;
	num = in.nextInt();
	System.out.print("Reverse of the input number is:");


Input your number and press enter: 
Reverse of the input number is:1098765


Author Biography.

Lokesh Gupta
Lokesh Gupta

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working in the information technology and services industry. I enjoy solving complex problems within budget and deadlines putting my skills on PHP, MySQL, Python, Codeigniter, Yii2, Laravel, AngularJS, ReactJS, NodeJS to best use. Through Knowledge of UML & visual modeling, application architecture design & business process modeling. Successfully delivered various projects, based on different technologies across the globe.

News & Blogs


Why shouldn’t you wait to jump onto Angular 2?

AngularJs is a JavaScript framework and is widely adopted framework in building Single Page Web A...


Difference between Sets vs. Arrays in JavaScript

The Set object type was introduced in the 2015 ECMAScript specification and is ready to be used i...


How to Implement Real Time Notification Using S...

Real time web/versatile application are getting to be well known step by step. Administrations li...