the scope of this problem is to have each emelent of the array displayed when I hit Enter.
I came across System.in.read() method and it kind of works but if I type a bunch of random characters and then hit enter it will not only display the next line but displays several elements in a row... I have tried different ways of solving it but to no avail.
Hopefully, someone can at least point me in the right direction.
Below is my simplified code.
Thanks
import java.io.IOException;
import java.util.Scanner;
public class classClass {
public static void main(String[] args) throws IOException {
int[] array = new int[10];
for (int i = 0; i < array.length; i++) {
array[i] = i;
}
for (int i = 0; i < array.length; i++) {
System.out.print(array[i]);
System.in.read();
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…