Eclipse从控制台读取StdIn(System.in),但不会给出任何输出 [英] Eclipse reading StdIn(System.in) from console, but will not give any output
问题描述
我的问题是Eclipse的控制台正在控制台中输入,但它永远不会停止输入,也不会给我任何输出。我创建了一个名为histogram()的方法,它采用整数M和整数数组a作为输入。我读取输入和生成输出的代码类似于
My problem is that Eclipse's console is taking input in the console, but it never stops taking input and will not give me any output. I created a method called histogram() that takes an integer M and an array a of integers as input. My code to read input and produce output looks like
int M = StdIn.readInt();
int[] a = StdIn.readAllInts();
int[] mossah = histogram(M, a);
for (int z = 0; z < M; z++) {
StdOut.printf("%d", mossah[z]);
}
我不允许使用其他库,所以请不要建议使用其他库。我在想,也许有某种键盘快捷键可以让控制台停止输入,但我不确定。我也尝试使用 StdIn.readInts()
,这给了我一个错误,它被折旧了,对于数组a的输入,但它也没有用。如果我在代码中为数组a赋值,我得到了我想要的输出,所以我的方法没有任何问题,只是我为你们提供的代码片段。非常感谢任何帮助。
I am not allowed to use other libraries, so please do not suggest one. I was thinking that maybe there's some kind of keyboard shortcut that will make the console stop taking input but I'm not sure. I also tried using StdIn.readInts()
, which gave me an error that it was depreciated, for array a's input, but it also did not work. If I assign values to array a in the code, I get my desired output, so there is nothing wrong with my method, just that code snippet I put for you guys. Any help is greatly appreciated.
推荐答案
假设您在Windows上按Ctrl-Z发送EOF字符
Assuming you are on windows hit Ctrl-Z to send the EOF character
这篇关于Eclipse从控制台读取StdIn(System.in),但不会给出任何输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!