public static void daYin(int n) {
//如果a大于9,那么整除10调用本身
if (n > 9) {
daYin(n / 10);
}
//a小于10时,模10打印
System.out.print(n % 10 + " ");
}
public static void main(String[] args) {
int num = 2020;
daYin(num);
}
运行结果: