【发布时间】:2014-04-06 14:09:52
【问题描述】:
只是想为我正在做的任务运行一些代码。这可能很简单,但对于我来说,我无法弄清楚为什么我会在第一行得到上述错误
(public WaterLog.......).
稍后我想通过这一行:
[ log = new WaterLog(8, damCapacity); ]
任何帮助将不胜感激,对不起,我是新手。
public class WaterLog(Integer windowSize, Integer maxEntry) {
private Integer size = windowSize;
private Integer max = maxEntry;
private ArrayList theLog(int windowSize);
private int counter = 0;
public void addEntry(Integer newEntry) throws SimulationException {
theLog.add(0, newEntry);
counter++;
}
public Integer getEntry(Integer index) throws SimulationException {
If (thelog.isEmpty() || thelog.size() < index) {
return null;
}
return thelog.get(index);
}
public Integer variation() throws SimulationException {
int old, recent = 0;
recent = thelog.get(0);
old = thelog.get(thelog.size-1);
return recent-old;
}
public Integer numEntries() {
return counter;
}
}
【问题讨论】:
-
一个方法不能包含其他方法。也许你的意思是公共类 WaterLog ?
-
WaterLog是类还是方法? -
它不是类声明,也不是构造函数,也不是方法。这是什么?
-
你把class,const混在一起了
-
是的,这是一门课,对不起,我编辑了。