Почему неправильно работает этот код?
1. Integer - неизменяемый. 
2. https://stackoverflow.com/a/40523
import java.util.Scanner;

public class Main {
    private static Integer invertDigits(Integer number) {
        Integer temp = 0;
        while (number != 0) {
            temp = temp * 10 + number % 10;
            number /= 10;
        }
        return temp;
    }

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        Integer number;
        System.out.print("Enter number: ");
        number = scanner.nextInt();
        System.out.println("Reverse digit order: " + invertDigits(number));
    }
}
1. Integer - неизменяемый. 
2. https://stackoverflow.com/a/40523
import java.util.Scanner;

public class Main {
    private static Integer invertDigits(Integer number) {
        Integer temp = 0;
        while (number != 0) {
            temp = temp * 10 + number % 10;
            number /= 10;
        }
        return temp;
    }

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        Integer number;
        System.out.print("Enter number: ");
        number = scanner.nextInt();
        System.out.println("Reverse digit order: " + invertDigits(number));
    }
}