+ 1

For loop in java not working

A basic program in java using for loop not working https://code.sololearn.com/cyhji4Tu1joS/?ref=app

2nd Jun 2019, 3:10 PM
SRIKANTH N
SRIKANTH N - avatar
3 Answers
+ 9
Bro remove ";" after the condition of for loop. public class Program { public static void main(String[] args) { for(int j=1;j<=10;j++) { System .out.println (j); } } }
2nd Jun 2019, 3:13 PM
Asmit joy
Asmit joy - avatar
+ 3
It doesn't work because at the end of the for loop you used a semicolon, and that confused the program for (int j = 1; j <= 10; j++); <- here { System.out.println(j); }
2nd Jun 2019, 3:14 PM
Airree
Airree - avatar
+ 1
Please don't spam the post 2 times https://www.sololearn.com/Discuss/1316935/?ref=app
2nd Jun 2019, 3:14 PM
Mo Hani
Mo Hani - avatar