How to Reverse the Number in Java

Reverse the Number in Java

Here, you will get the program code to Reverse the Number  in Java programming.

Reverse a number is a mathematical operation in which the digits of a given number are reversed to create a new number.

For example, if the number is 2345, then the reverse of that number would be 5432.

Reverse the Number in Java using For Loop

Output

Reverse the Number in Java

Reverse Number in Java using While loop

Output

C:\CodeRevise\java>javac ReverseTheNumber.java

C:\CodeRevise\java>java ReverseTheNumber
Enter a number:
10976
Reverse Number of 10976 is = 67901

Reverse Number in Java without Loop

Output

C:\CodeRevise\java>javac ReverseNumWithoutLoop.java

C:\CodeRevise\java>java ReverseNumWithoutLoop
Enter a number:
2345
Original Number: 2345
Reversed Number: 5432

 

 

Check out our other Java Programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top