public class PrintDigits { public static void main(String[] args) { int n = 123; System.out.println(n % 10); n = n / 10; // n is now 12, not 12.3 because n is an integer System.out.println(n % 10); n = n / 10; // n is now 1, again, not 1.2 System.out.println(n % 10); } }