-1
public class Temperaturevar {
public int T1 = 0;
public int T2;
public int T3;
public int T4;
public int T5;
public int T6;
public int T7;
public int T8;
public int T9;
public int T10;
public Temperaturevar() {
}
public void TemperatureVar() {
T1 = T1;
T2 = T1 + 10;
T3 = T2 + 10;
T4 = T3 + 10;
T5 = T4 + 10;
T6 = T5 + 10;
T7 = T6 + 10;
T8 = T7 + 10;
T9 = T8 + 10;
T10 = T9 + 10;
//increase Temperature value by 10
}
public int getValue() {
return T1;
}
public void main(String[] args) {
System.out.println("T1: " + T1.getValue());
System.out.println("T2: " + T2.getValue());
System.out.println("T3: " + T3.getValue());
System.out.println("T4: " + T4.getValue());
System.out.println("T5: " + T5.getValue());
System.out.println("T6: " + T6.getValue());
System.out.println("T7: " + T7.getValue());
System.out.println("T8: " + T8.getValue());
System.out.println("T9: " + T9.getValue());
System.out.println("T10: " + T10.getValue());
}
}
我是比較新的Java編程和了解的基礎知識,但我不斷遇到int cannot be derefrenced
錯誤,當我嘗試打印出他對T1
值 - T10
。我也嘗試過使用點擊方法成功,但後來我遇到了問題,我必須將相應的編號存儲到變量中,以便我可以將其引用到另一個類中。遇到derefrencing錯誤
你期望'T1.getValue()'返回什麼?爲什麼? – shmosel