我有一个类Cell
和一个类Neighbour
扩展Cell
。但是当我尝试将 an 传递ArrayList<Neighbour>
给期望ArrayList<Cell>
. 我错过了什么?
class Cell {
PVector pos;
Cell(PVector pPos) {
pos = pPos.get();
}
}
class Neighbour extends Cell {
int borders = 0;
Neighbour(PVector pPos) {
super(pPos);
}
}
private int inSet(PVector pPos, ArrayList<Cell> set) {
[...]
return -1;
}
[...]
ArrayList<Neighbour> neighbours = new ArrayList<Neighbour>();
PVector pPos = new PVector(0, 0);
[...]
inSet(pPos, neighbours);
最后一行抛出错误`The method iniSet(PVector, ArrayList) is not applicable for the arguments (PVector, ArrayList);
谢谢你的帮助!