Java Programs

Write a Java program to reverse the given number ?


/* Java Program to reverse the Given Number */
public class ReverseNumber {
    public static void main(String[] args) {
        int number = 321; /* give input here */
        int rev = 0;
        int num = number;
        while (num > 0) {
             int rem = num % 10;
             rev = rev*10+ rem;
             num /= 10;
        }
        System.out.println("Reverse Of Given Number is : "+rev);
    }
}

www.000webhost.com