0
Why I obtain this error although I declared the type of I as int in the for loop?
Import java.util.*; Public class prog{ public static void main (String[] args){ int sum=0; for(int i=0;i<3;i++); sum+=i; System.out.println(sum); } }
4 Respuestas
+ 2
because of the semicolon after for loop
+ 2
Thanks Friends for your help 😊
+ 1
Hichem GOUIA , I think your problem is that you put semicolon in the line of the loop. Loop has to be enclosed in curly brackets.
0
No it's not because of the semicolon.
If I add a new line int i=0; After the int sum=0; the code compiles
I have a doubt here if the i is considered as a local variable for the for loop...