Program to demonstrate how to reverse a number in Java
import java.util.Scanner; public class ReverseNumber { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter a number to reverse : "); int original = scanner.nextInt(); int reverse = 0; int remainder; while(original != 0) { remainder = original % 10; reverse = reverse * 10 + remainder; original = original / 10; } System.out.println("Reverse of number is : " + reverse); } }Output of the program :