【发布时间】:2013-06-02 19:20:04
【问题描述】:
我正在尝试使用一种方法创建一个类,该方法可以打印任意两个给定整数之间的所有整数。这就是我现在得到的-
public class IntList {
public static void main(String[] args) {
int start = Integer.parseInt(args[0]);
int stop = Integer.parseInt(args[1]);
for (int i = start + 1; i < stop; i++) {
System.out.print(i);
}
}
}
这不会编译,我收到 2 个错误,提示“解析时到达文件末尾”,第 4 行和第 5 行各一次。
【问题讨论】:
-
好的。还有什么问题?
-
System.out.print(i);在同一行打印,但 printf 添加了换行符。