执行下面的程序后,打印 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");
}
}
}
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
{/*...*/}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句