public static void main(String[] args) { int i = 9876; int num = caleReverseNum(i); System.out.println(num); } /** * 时间复杂度为n的位数 */ static int caleReverseNum(int num) { int rev = 0; while (num != 0){ rev = rev * 10 + num % 10; num /= 10; } return rev; }