I am coding a little election Program for the upcoming Election's in Germany. Well, it is not working.
public static void main(String[] args)
{
String _Kandidat1;
String _Kandidat2;
_Kandidat1 = JOptionPane.showInputDialog("Do you Vote for the AFD or for the CDU ?");
if (_Kandidat1 == "AFD")
System.out.println("The AFD won the election!");
else
System.out.println("The CDU won the election!");
}
}
If I type in "AFD" it says the CDU won. If I type in "CDU" in nothing happens.
I'm not sure, but I think the mistake is in if (_Kandidat1 == "AFD")
Any solutions?