再次提出初学者问题!当运行以下时,即使输入了正确的名称“matthew”,我也会出现“False”对话框。
我肯定错过了一些东西!
import javax.swing.*;
public class IfStatmentString
{
public static void main(String[] args)
{
String name = "";
name = JOptionPane.showInputDialog(null, "Please enter User Name:","Name",JOptionPane.QUESTION_MESSAGE);
if (name == "matthew" )
{
JOptionPane.showMessageDialog(null,"True");
}
else
{
JOptionPane.showMessageDialog(null,"False");
}
}
}