简体   繁体   English

Eclipse从控制台读取StdIn(System.in),但不会提供任何输出

[英]Eclipse reading StdIn(System.in) from console, but will not give any output

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. 我的问题是Eclipse的控制台正在控制台中接受输入,但是它永远不会停止接受输入,并且不会给我任何输出。 I created a method called histogram() that takes an integer M and an array a of integers as input. 我创建了一个称为histogram()的方法,该方法将一个整数M和一个整数数组a作为输入。 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]);
    } 

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. 我还尝试使用StdIn.readInts() ,这给了我一个错误,对于数组a的输入,它已被贬值,但它也不起作用。 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. 如果我在代码中为数组a赋值,我将得到所需的输出,因此我的方法没有任何问题,只是我为你们提供的代码段。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

假设您在Windows上,按Ctrl-Z发送EOF字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM