Local variable needs to be declared final
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm receiving the error "local variable box is accessed from within inner class; needs to be declared final". That seems alright, but I don't really think it's the best solution, so I was hoping maybe someone else can help me out. Here is my code: public void showPublisherBox(JComboBox box) { if (publisherBox == null) { publisherBox = new AddPublisherForm(); publisherBox.setLocationRelativeTo(this); } publisherBox.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { this.populatePublishers(box); } private void