因为我是新的java。我已经搜索了有关在Java中的静态平均值,我得到了堆栈溢出的解决方案here但是当我编译它显示错误。有人可以建议我错在哪里?<identifier>预计java编译错误
public class Hello
{
// value/method
public static String staticValue;
public String nonStaticValue;
}
class A
{
Hello hello = new Hello();
hello.staticValue = "abc";
hello.nonStaticValue = "xyz";
}
class B
{
Hello hello2 = new Hello(); // here staticValue = "abc"
hello2.staticValue; // will have value of "abc"
hello2.nonStaticValue; // will have value of null
}
知道static'成员变量的'的使用,并且还非静态成员变量 –