for
格式:for(初始化表达式;循环条件表达式;循环后的操作表达式)

{

执行语句:循环体

}

 

------------------------------------

循环结构 for

-----------------------------------------------------------

只要循环条件表达式运算的结果为boolean则for可以进行循环,如果循环条件表达式不是Boolean会提示类型错误

int a=1;
for(System.out.println("a");a<3;System.out.println("c")){
System.out.println("b");
a++;
}

 

输出为:

a
b
c
b
c

 

相关文章: