Java - Write code to do int Reverse

Requirements

Write code to do int Reverse

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        int num = 42;
        System.out.println(intReverse(num));
    }//from   ww  w .jav  a2 s . c  om

    public static int intReverse(int num) {
        char[] reversed = ("" + num).toCharArray();
        String reversedInt = "";

        for (int i = reversed.length - 1; i >= 0; i--) {
            reversedInt += reversed[i];
        }

        return Integer.parseInt(reversedInt);
    }
}