我目前正在学习Java,这个问题让我困惑了一段时间,尽管我确定答案很简单.我想知道是否有通过扩展某些类获得的隐藏方法,这样你可以调用子类中的方法而不引用super.method(...?例如,看看这个ButtonPanel类:
class ButtonPanels extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public ButtonPanels(){
JButton yellow = new JButton("Yellow");
JButton blue = new JButton("Blue");
JButton red = new JButton("Red");
add(yellow);
add(blue);
add(red);
}
}
Run Code Online (Sandbox Code Playgroud)
这里的"添加"方法......它们来自哪里?看起来写super.add工作得非常好,这让我很困惑.难道你不需要在超级课程中调用所有方法吗?
| 归档时间: |
|
| 查看次数: |
906 次 |
| 最近记录: |