我正在关注本书中的一本书,给出的代码我试图编译它,但它显示错误,这里是代码 -
class TapeDeck {
boolean canRecord = false;
void playTape() {
System.out.println("tape recording");
}
void recording() {
System.out.println("tape recording");
}
}
class TapeDeckTestDrive {
public static void main (String [] args) {
TapeDeck t = new TapeDeck( );
t.canRecord = true;
t.play();
if (t.canRecord == true) {
t.recordTape();
}
}
}
一个错误是....
TapeDeck.java:16: error: cannot find symbol
t.play();
^
symbol: method play()
location: variable t of type TapeDeck
TapeDeck.java:19: error: cannot find symbol
t.recordTape();
^
symbol: method recordTape()
location: variable t of type TapeDeck
2 errors