我有这行代码.
class ButtonPanel extends JPanel implements ActionListener
{
public ButtonPanel()
{
yellowButton = new JButton("Yellow");
Run Code Online (Sandbox Code Playgroud)
它工作,我认为Java在创建像这样的jButton实例之前需要知道yellowButton的类型?
JButton yellowButton = new JButton("Yellow");
Run Code Online (Sandbox Code Playgroud)
谁能解释一下这是如何工作的?