Why does adding a semicolon after 'for (…)' change the meaning of my program so dramatically?

前端 未结 6 2175
猫巷女王i
猫巷女王i 2020-12-04 04:30

I wrote the following class:

  public class TestOne {
     public static void main(String[] args) {
        int count = 0;
        for (int i = 0; i < 100         


        
6条回答
  •  暖寄归人
    2020-12-04 04:57

    after iteration ending you are incrementing count value

    After for loop you are using semi colon so your for loop is end

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

    { count++; }

    count incremental is not in the for loop. it is outside the loop;

提交回复
热议问题