问题
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