These days, when I’m reading some other guy’s code, I encounter some problem. In these code, I can read following codes:
JButton button = new JButton("OK");
button.setActionCommand("OK");
button.addActionListener(this);
……
actionPerformed(e) {
String s = e.getActionCommand();
if(s=="OK")
……
}
Look, it use “==” but not “equals” here. “Oh, it must be a bug!”, I told myself. But, wait, when I excuted the [...]