因爲我是新的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'成員變量的'的使用,並且還非靜態成員變量 –