Goodday大家,类型表达的必须是一个数组类型,但它解析为“温度” -Java
所以,我提出的一类的温度,这有一个构造,使温度。温度是一个由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错误,但我找不到它。
在此先感谢。 大卫
对象如果有错误,请张贴异常或错误,请的堆栈跟踪。 – Crazenezz