I have this method in java I have found here.
private void pressAnyKeyToContinue() {
try {
System.in.read();
}
catch(Exception e) {}
}
The problem I have is when I want to call it several times. I use it in a method that prints a message like this:
private void keyMessage() {
System.out.print("Press any key to continue...");
pressAnyKeyToContinue();
And then I use this method here:
public void method() {
message1();
for (Class class : classes) {
keyMessage();
}
}
The problem I have is when I call the method() first it prints.
Otuput: Press any key to continue...
Then I press a key + enter. Until here all perfect but then it prints:
Output: Press any key to continue... //* times of the loop
I mean it does not let me press any key. It simply goes until the end of the loop.
Thank you for answering and sorry about my english. I know it is not good.