1、java 中的 for 循环:
int x = 1;
for(system.out.println("a");x<3; system.out.println("c"),x++)
{
system.out.println("d");
}
输出结果为
a
d
c
d
c
2、无限循环的最简单表现形式:
for(;;){ } /*for 中判读表达式中默认为true*/
while(true){ }
3、java 中for 和 while 的区别
控制循环变量中的次数,只在循环体中使用则使用for更加优化内存,而控制循环次数的变量在循环体外部使用的则使用while。
int x = 1;
for(system.out.println("a");x<3; system.out.println("c"),x++)
{
system.out.println("d");
}
输出结果为
a
d
c
d
c
2、无限循环的最简单表现形式:
for(;;){ } /*for 中判读表达式中默认为true*/
while(true){ }
3、java 中for 和 while 的区别
控制循环变量中的次数,只在循环体中使用则使用for更加优化内存,而控制循环次数的变量在循环体外部使用的则使用while。