Reverse number Java

Reverse number Java

If you want to reverse number using java then please have sample program below. In this example integer 1234567890 will be reversed and out put will be printed on console.

package com.javahonk;

public class ReverseNumber {

    public static void main(String[] args) {

        int nubmerToReverse = 1234567890;
        int reverse;
        while (nubmerToReverse != 0) {
            reverse = nubmerToReverse % 10;
            nubmerToReverse = nubmerToReverse / 10;
            System.out.print(reverse);
        }

    }

}

Output:

Reverse number Java

Leave a Reply

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