有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java的机制是什么?

执行下面的程序后,打印5行hello java代码。所以我知道i++是否有打印10行。我需要知道在这个程序中,I+=2的职责是什么

 class Example{
      public static void main(String args[]){
            for(int i=0; i<10; i+=2){
            System.out.println("Hello Java");
            }
       }
   }

共 (1) 个答案

  1. # 1 楼答案

    for(int i = 0; // i is an variable integer, which is 0 from the start
        i < 10;    // if i is 10 or above, the loop is finished, else the code runs
        i += 2)    // after the code is ran, 2 will be added to the variable i 
    {/*...*/}