为什么在方法里不能定义STATIC类型的变量?
为什么在方法里不能定义STATIC类型的变量?
2006-05-07 11:32
public class a
{
public static void main(String args[])
{
static int d;
System.out.println(d);
}
}
为什么错?
2006-05-07 18:51
好象a 得大写吧?
2006-05-07 19:49
不是static的问题
方法中的变量必须显式初始化
static int d;//你没有给d赋初值 当然错了
[此贴子已经被作者于2006-5-7 22:52:37编辑过]

2006-05-07 22:52
public class a
{
public static void main(String args[])
{
static int d=0;
System.out.println(d);
}
}
错的
2006-05-07 22:59
2006-05-07 23:13
public class a
{
static int d=0;
public static void main(String args[])
{
//static int d=0;
System.out.println(d);
}
}

2006-05-08 15:26
2006-05-08 15:31
2006-05-08 21:14
2006-05-09 11:02