Cannot refer to non variable inside Action listener (Jframe)

 ̄綄美尐妖づ 提交于 2019-12-02 07:54:34

In Java you cannot refer to not final variables inside anonymous inner class. You attempt to access array3 inside anonymous implementation of ActionListener. You can simply change array3 to final, ie:

final String [] array3 = new String [3];

Also, to print a content of array you can use Arrays.toString():

JOptionPane.showMessageDialog(null, "The Colors are : " + (Arrays.toString(array3)));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!