刚学for (int x=1,x<=3;x++)
{
for(int y=1,y<=3;y++)
{
System.out.print("*");
}
System.out.println("*");
}打出
****
****
****
内循环总多出一位,怎么回事呢?
{
for(int y=1,y<=3;y++)
{
System.out.print("*");
}
System.out.println("*");
}打出
****
****
****
内循环总多出一位,怎么回事呢?
{
for(int y=1,y<=3;y++)
{
System.out.print("*");
}
System.out.println();
System.out.println("*");
}
运行之后比较一下
{
for(int y=1;y<=3;y++)
{
System.out.print("*");
}
System.out.println();
System.out.println("*");
}
for循环的格式:for(表达式1;条件;表达式2){}
两个都是分号(;),不是(,)