我正在为我的计算机科学课做天气处理器作业,我的一段代码出了点问题。我不知道如何处理这个问题,所以任何帮助都是很好的。这是我的代码:
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/等等,它告诉我getHIGHS方法对于类型对象是未定义的。我哪里出问题了?我有另一个类,它具有此代码中的方法的getter。
发布于 2016-04-09 21:35:28
错误消息意味着对象类没有名为getHIGHS的方法,至少没有java.lang.Object。
医生:https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html
您可能正在使用具有对象类的某种lib,然后您必须导入该包.
但如果你使用的是第三部分库,我建议你看一下文档。
https://stackoverflow.com/questions/36522915
复制相似问题