Java Reverse Number

 

Program to Reverse the digits of a Number.

/**
 * This program is used to reverse the digits of a number.
 * @author W3schools360
 */
public class ReverseNumberExample {
	static void reverseNum(int num){
		//Print reverse number.
		System.out.println("Numer before reverse process: " + num);
		int newNum = 0, reminder, temp; 
		temp = num; 
		//Reverse the digit's of the number. 
		while(temp != 0){ 
			reminder = temp
			newNum = newNum*10 + reminder; 
			temp = temp/10; 
		} 
		//Print reverse number.
		System.out.println("Numer after reverse process: " + newNum);
	}
	
	
	public static void main(String args[]){ 
		//method call 
		reverseNum(34267); 
	}
}

Output:

Numer before reverse process: 34267
Numer after reverse process: 76243