1
我正在學習java的過程。java圍繞類的括號存儲引用按鈕
我從Java引用這段代碼: -
public class ButtonList extends Applet implements ActionListener {
String msg = "";
Button bList[] = new Button[3];
public void init() {
Button yes = new Button("Yes");
Button no = new Button("No");
Button maybe = new Button("Undecided");
// store references to buttons as added
bList[0] = (Button) add(yes); <<<<<<<<<<<<<<<<<<<<<<<<<<<<< here
bList[1] = (Button) add(no);
bList[2] = (Button) add(maybe);
// register to receive action events
for(int i = 0; i < 3; i++) {
bList[i].addActionListener(this);
}
}
而且我不知道什麼是 「(按鈕)添加(是)」 表示。
如果在前面的 段落中聲明爲按鈕,爲什麼bList []應重新指定爲Button。
還有什麼Button whithin括號在這裏代表?