【发布时间】:2018-10-12 20:16:02
【问题描述】:
编译器在这里给了我一个非静态方法错误,我已经知道这并不意味着它一定是问题但我真的找不到其他任何东西,特别是因为我在不同的类中有相同的方法只是因为传球一切正常。
public Map<Integer, Map<Integer, Double>> setup(ArrayList<RunPlay> play){
Map<Integer, Map<Integer,Double>> map =
plays.stream()
.collect(
Collectors.groupingBy(RunPlay::getYardline, Collectors.groupingBy(RunPlay::getDown, Collectors.averagingDouble(PassPlay::getPoints)))
);
return map;
这是 RunPlay 类:
public class RunPlay {
private int yardline;
private int down;
private int togo;
private int gained;
private int td;
public RunPlay(int yardline, int down, int togo, int gained, int td){
this.down=down;
this.gained=gained;
this.td=td;
this.togo=togo;
this.yardline=yardline;
}
public double getPoints(){
double result=0;
result+=((getGained()*0.1)+(td*6));
return result;
}
public int getYardline() {
return yardline;
}
public int getGained() { return gained; }
public int getDown() { return down; }
public int getTd() {
return td;
}
public int getTogo() {
return togo;
}
}
【问题讨论】:
标签: java java-stream collect