大家好,
所以我做了一个温度类,它有一个构造器来调节温度。
温度是2个数字[寒冷,热度]的数组列表。
public int hotness;
public int coldness;
public int[] temperature;
public int maxTemperature = 10000;
//Constructor Temperature
public Temperature(int hotness, int coldness) {
/**
* A constructor for the Array Temperature
*/
maxTemperature = getMaxTemperature();
if(hotness <= maxTemperature && coldness <= maxTemperature)
temperature[0] = coldness;
temperature[1] = hotness;
}现在我想进入另一个课程并使用该对象温度来做一些计算。这是它的代码。
//Variabels
public int volatility;
private static Temperature temperature;
private static int intrensicExplosivity;
public static int standardVolatility(){
if(temperature[0] == 0){
int standardVolatility = 100 * intrensicExplosivity * (0.10 * temperature[1]);
}所以现在我得到的错误:表达式的类型必须是数组类型,但它解析为“温度”
任何解决方案
我对Java很陌生,所以可能只是一些synthax错误,但我无法找到它。
提前致谢。
大卫