-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