The following program\'s goal is to ask the user to input a resistor value, then of which the program will output the corresponding colors for each digit. This thus not include
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)));