how to reverse a number in java using for loop

We try to solve specific logical problems in Java using some form of loops. In this post we present an example on how to

how to reverse a number in java using for loop

Below is a simple solution to the problem:
/**
 * An example program that shows how to reverse a number in java using for loop.
 */
public class ExampleProgram {
    public static void main(String[] args) {
        System.out.println( 125 + " in reverse is = " + reverse(125));
        System.out.println( 321 + " in reverse is = " + reverse(321));
        System.out.println( 2019 + " in reverse is = " + reverse(2019));
    }
    public static int reverse(int n) {
        int reverse = 0;
        for (; n > 0;) {
            int digit = n % 10;
            reverse = (reverse * 10) + digit;
            n = n / 10;
        }
        return reverse;
    }
}

And below is output to the code:

125 in reverse is = 521
321 in reverse is = 123
2019 in reverse is = 9102