是否可以向匿名类传递参数或访问外部参数?例如:
int myVariable = 1; myButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // How would one access myVariable here? } });
是否有方式访问myVariable或传递myVariable而不将侦听器创建为实际的命名类?
相似问题
领取专属 10元无门槛券
AI混元助手 在线答疑
洞察 腾讯核心技术
剖析业界实践案例