你能幫我解決這個代碼嗎?簡單的Java接口實現
interface Speaker {
void speak();
}
public class Politician implements Speaker {
public void speak() {
System.out.println("Politician speaking");
}
}
public class Lecturer implements Speaker {
public void speak() {
System.out.println("Lecturer spaeking");
}
}
public class SpeakerTest {
public static void main(String[] args) {
//??????????????? how to execute?
}
}
你想做什麼? – BobTheBuilder
這裏的問題很明顯:如何「instanciate」並使用界面:) Upvoting ... – user3001