'input.next() keeps waiting for an input
Note: My code is written in Java.
I am making a reaction time test which works completely well otherwise. However, when I press enter it continues to wait for an input, which makes the reaction time test less effective. What should I write so that the Enter Key can be taken as an input rather than having to type a character then press enter.
Solution 1:[1]
You could use input.nextLine();
Solution 2:[2]
You can write input.nextLine() which returns whole input except for the line separator, as it finds line separator it skips the input.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jhanzaib Humayun |
| Solution 2 | Tyler2P |
