Whats wrong with this please? Looping a string input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats wrong with this please? Looping a string input

hey, I keep getting time limit exceeded i just want to loop my scanner string 10× i cant see whats wrong with it String x; Scanner scan = new Scanner(System.in); x = scan.nextLine(); int a = 10; while(a>0); System.out.println(x);a--;

27th Jun 2017, 8:32 AM
D_Stark
D_Stark - avatar
2 Answers
+ 1
When trying to figure out a problem with loops, try break; on the first try, then you can see your output instantly. This helps me a lot of error_logs
27th Jun 2017, 10:59 AM
Harm Zeinstra
Harm Zeinstra - avatar
0
its ok i figured it out i needed to put the System.out.println inside {} 😀
27th Jun 2017, 8:49 AM
D_Stark
D_Stark - avatar