Test.java
package Hcybx;
public class Test {
public static void main(String[] args) {
int integer = 54321;
int units = 54321 % 10; // 个位
int tens = 54321 / 10 % 10; // 十位
int hundreds = 54321 / 100 % 10; // 百位
int thousands = 54321 / 1000 % 10;// 千位
int tenThousands = 54321 / 10000;//万位
// 依此类推
System.out.println("个位是:" + units);
System.out.println("十位是:" + tens);
System.out.println("百位是:" + hundreds);
System.out.println("千位是:" + thousands);
System.out.println("万位是:" + tenThousands);
}
}
运行结果: