public class PrintNumbers {
    public static void main(String[] args) {
        for (int i = 1; i <= 1000; i++) { // 循环遍历1到1000内的所有数字
            System.out.print(i); // 输出当前数字
            if (i != 1000) { // 判断是否为最后一个数字
                System.out.print(','); // 如果不是最后一个数字,则输出逗号
            }
        }
    }
}
Java 打印 1 到 1000 的数字,用逗号分隔

原文地址: https://www.cveoy.top/t/topic/j7Yw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录