【发布时间】:2012-05-10 15:53:45
【问题描述】:
大家好,
所以我创建了一个温度类,它有一个构造函数来产生温度。 温度是 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 很陌生,所以可能只是一些语法错误,但我就是找不到。
提前致谢。 大卫
【问题讨论】:
-
如果有错误,请贴出异常或错误的堆栈跟踪。
标签: java