我有三个班级:
public class BikeSystem {
static Bicycle[] bicycleArray = new Bicycle[100];
static int currentBikes = 0;
public static void addUnicycle() {
bicycleArray[currentBikes] = new Unicycle();
currentBikes++;
}
public static void addUniWheel() {
for (int i=0; i < currentBikes; i++) {
if (bicycleArray[i] instanceof Unicycle)
bicycleArray[i].addWheel();
}
}
}
public class Bicycle {
// some variables
}
public class Unicycle extends Bicycle {
private int wheels;
public boolean addWheel() {
wheels++;
return true;
}
}
bicycleArray[i].addWheel()
但是,当我尝试在 BikeSystem 类中调用该方法时,我不断收到“找不到符号”错误。我该如何解决这个问题?