我有这行代码。
class ButtonPanel extends JPanel implements ActionListener
{
public ButtonPanel()
{
yellowButton = new JButton("Yellow");
它有效,我认为Java需要在创建这样的jButton实例之前知道yellowButton的类型?
JButton yellowButton = new JButton("Yellow");
有人可以解释这是如何工作的吗?