for(int y = 1;y<4;y++) //不看程序在这里在加个for循环呢。不懂你什么意思。可以加的
{}
y--;
System.out.println("y="+y);
}
}
}
//-----------------------------------------
class Test2
{
public static void main(String[] args)
{
{
System.out.println("hehe");
}
System.out.println("over---"); //这个对
//局部变量块的作用:局部变量在大括号范围内有作用,括号内执行完就释放。
int x = 4; 。
{
System.out.println("hehe");
}
System.out.println("over---"+x); //这个也对
int x = 4; //这个还对
System.out.println("hehe");
System.out.println("over---"+x);
}
}
复制代码
作者: 范泰洋 时间: 2012-7-9 18:46
//-----------------------------------------
class Test2
{
public static void main(String[] args)
{
//现在我才知道局部代码块的作用
int x = 4; 。
{
System.out.println("hehe");
}
System.out.println("over---"+x); //这个对
}
} 作者: 李志群 时间: 2012-7-9 19:07
class Test
{
public static void main(String[] args)
{
for(int x=0; x<4;x++) //注释:for循环里不能有两个变量。
{
int y = 4;
System.out.println("x="+x);
y--;
System.out.println("y="+y);
}
for(int x=0; x<4;x++)
{
// int y = 4;//你这定义Y了 for循环里面怎么还定义呢? 我晕死这里要是定义Y for循环里就不用定义了