java的类的定义.
为什么下面两个类的定义都是不对的!!!class MyClass
{
private int Val;
public static int getVal()
{
return Val;
}
}
class MyClass
{
private int Val;
public static int setVal(int Val)
{
this.Val=Val;
}
}
class MyClass
{
void Val(){
}
public static void getVal()
{
}
}
class MyClass
{
private int Val;
public static int getVal() //你這里是静态方法,不能访问非静态的变量
{
return Val;
}
}