I am confused. I tried using
final String usr;
and trying to change its value never worked, but when I used an array final String[] usr = {"", ""};
, it worked. I even accessed it from this
sgnup.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
user[0] = sUsr.getText();
}
});
I find it very confusing because my understanding of final
is that a variable declared with final
and add a value to it, the value never changes. But why did an array with final
work? I can even set a text to one of those arrays.