+ 1

No such element? Please help!

I have the following: import java.util.Scanner; public class Program { public static void main(String[] args) { int a = 0; while (a != 3) { Scanner gs = new Scanner(System.in); System.out.println(gs.next()); gs.close(); a++; } } } It keeps throwing the noSuchElement error. What's going on? Is there a way I can get it to ask me for input multiple times? Help and explanation would be much appreciated.

10th Apr 2017, 2:49 PM
Mikolaj Figurski
Mikolaj Figurski - avatar
1 Odpowiedź
+ 10
No, you have to input all values at the playground at once, separated by line breaks. See this post: https://www.sololearn.com/discuss/217079/?ref=app
10th Apr 2017, 2:51 PM
Tashi N
Tashi N - avatar