In array, what happen after for statement we put semicolon? It is does not excute anything or it just ignore the for statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

In array, what happen after for statement we put semicolon? It is does not excute anything or it just ignore the for statement?

For example System.out.print("Three cheer for Ironman!") for (int i=0 ; i <4 ; i++); System.out.println("HIP HIP,HORAY!");

13th Feb 2019, 3:42 PM
Niesa Irdina
Niesa Irdina - avatar
1 Answer
+ 1
The semicolon ensures that the code that comes after that does not belong to the loop. So the loop does only what is inside the header, in your case i++ until i = 4. Edit: for(int i = 0;i<=4;System.out.println(i++)); //prints the numbers from 0 to 4
14th Feb 2019, 12:40 AM
Denise Roßberg
Denise Roßberg - avatar