for(int i=0;i<=5;i++) | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

for(int i=0;i<=5;i++)

Why after i++ there is no any semicolon( ; ).i++ is also a statement . when we use while loop there is i++; why not here?

11th Apr 2021, 3:45 AM
Jimmy Wilk
Jimmy Wilk - avatar
3 Antworten
+ 3
All stmts in Java ends with a semicolon .Thats why i++ being a stmt inside while loop comes with a semicolon. Whereas i++ in for loop is written in its iteration slot . Kindly have a read : https://www.sololearn.com/learn/Java/2147/?ref=app
11th Apr 2021, 3:58 AM
Alphin K Sajan
Alphin K Sajan - avatar
0
Plzz can u tell me briefly
11th Apr 2021, 4:19 AM
Jimmy Wilk
Jimmy Wilk - avatar
0
The things inside the parentheses of for loop are not statements. The syntax of for loop is for(initialization; condition; increment/decrement) The semicolons are to seperate those three things. So there is no need for a semicolon at the end since there is nothing after that
11th Apr 2021, 4:40 AM
Arun Ruban SJ
Arun Ruban SJ - avatar