I am new to Java, and I am really confused by equality. Here is my current code:
Even if I type in yes at the prompt, it always prints "You chose no". Is there something I don't understand about equality comparisons in Java? Please give me a modified version of my code that will work.
Thanks,
Anon
Code:
String dm = JOptionPane.showInputDialog("Yes or no?");
if(dm=="yes")
{
System.out.println("You chose yes.");
}
else
{
System.out.println("You chose no.");
}
Thanks,
Anon
Comment