[英]Method undefined for type?
我正在为我的计算机科学课做一个天气处理器作业,而我在一段代码上遇到了麻烦。 我不确定如何解决该问题,因此任何帮助都将非常有用。 这是我的代码:
import java.util.*;
import java.util.GregorianCalendar;
public class Info {
Object data;
String weatherRecord[][][] = new String[0][0][0];
int index = 0;
int HIGHS, LOWS, WIND, GUST, PRECIP;
public void weatherData () {
data = data;
}
final String[] locationNames = {"Eagle, NE", "New York, NY", "Houston, TX", "Los Angeles, CA"};
final int[] monthLength = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
{
for (int i = 0; i < weatherRecord.length; i++) {
GregorianCalendar dateInfo = new GregorianCalendar(2008, 0, 1);
System.out.println((dateInfo.get(Calendar.MONTH) + 1)+ "/" +
dateInfo.get(Calendar.DAY_OF_MONTH)+ "/" +
dateInfo.get(Calendar.YEAR));
for (int j = 0; j < weatherRecord[i].length; j++) {
for (int k = 0; k < monthLength[j]; k++) {
weatherRecord[i][j][k] = new weatherData();
weatherRecord[i][j][k].setLocation(locationNames[i]);
weatherRecord[i][j][k].setDate((GregorianCalendar) dateInfo.clone());
weatherRecord[i][j][k].setHighTemp(data.getHIGHS(index));
weatherRecord[i][j][k].setLowTemp(data.getLOWS(index));
weatherRecord[i][j][k].setWind(data.getWIND(index));
weatherRecord[i][j][k].setGust(data.getGUST(index));
weatherRecord[i][j][k].setPrecip(data.getPRECIP(index));
index++;
dateInfo.add(Calendar.DAY_OF_MONTH, 1);
}
System.out.println((dateInfo.get(Calendar.MONTH)+1) + "/" +
dateInfo.get(Calendar.DAY_OF_MONTH) + "/" +
dateInfo.get(Calendar.YEAR));
}
}
}
private int setLocation(String string) {
// TODO Auto-generated method stub
return 0;
}
}
我遇到麻烦的部分是data.getHIGHS / LOWS / etc,它告诉我getHIGHS
方法对于对象类型是未定义的。 我要去哪里错了? 我还有另一个类,该类具有此代码中方法的吸气剂。
错误消息的意思很简单,Object类没有名为getHIGHS的方法,至少不是java.lang.Object
Doc: https : //docs.oracle.com/javase/7/docs/api/java/lang/Object.html
您可能正在使用某种具有Object类的库,然后必须导入该程序包。
但是,如果您使用的是第3部分库,我建议您看一下文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.