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

为君一笑 提交于 2020-01-03 03:13:13

问题


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]);
    } 

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.


回答1:


Assuming you are on windows hit Ctrl-Z to send the EOF character



来源:https://stackoverflow.com/questions/33066724/eclipse-reading-stdinsystem-in-from-console-but-will-not-give-any-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!