java - 通过 ideone 运行时,扫描仪上的 NoSuchElementException 有什么问题?
问题描述
我在第 12 行的扫描仪上收到了 NZEC,我在这里阅读了一些博客和几个问题,说问题正在关闭流,但我不明白发生在哪里。这个错误只发生在ideone上,它不会发生在netbeans上。
public static void main (String[] args) throws java.lang.Exception
{
int t;
List<Integer> k = new ArrayList();
Scanner in = new Scanner(System.in);
do {
//Exception in thread "main" java.util.NoSuchElementException happens on this line
t = Integer.parseInt(in.next());
} while (t < 0 || t > 1000000);
do {
k.add(Integer.parseInt(in.next()) + 1);
t--;
} while (t > 0);
for (int num : k) {
while (!isPrime(num)) {
num++;
}
System.out.println(num);
}
}
解决方案
推荐阅读
- python-3.x - 如何从通过导入 .txt 文件生成的列表中选择随机作品?
- javascript - 材质ui表,单元格编辑日期验证
- c++ - 具有二元与等于 0 的整数对
- android - Ljava/nio/Byffer;-;address:J - 灰名单
- c# - 在 UnitTest Thread.sleep(1300) 中只等待 ~300ms
- laravel - 如何在 laravel 5.7 控制器中将重复行合并为一行
- python - 如何使用 t-SNE 进行降维以可视化我的 300 维词嵌入?
- ios - Xcode 11 swift包管理器无法解析包
- javascript - 如果回调是参数化箭头函数,如何删除事件侦听器
- python-3.x - 如何使用熊猫从网站上读取 html 来抓取表格中的表格