简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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