How to check string variable with if - else?

Viewed 25
package test;
import javax.swing.JOptionPane;

public class Daylamaincuabomay {
   
    public static void main(String[] args) {
        
        String name = JOptionPane.showInputDialog("Password: ");
        if (name == "F")
          JOptionPane.showMessageDialog(null, "Welcome back"); 
        else
          JOptionPane.showMessageDialog(null, "Error, retry again"); 
   }
}
0 Answers
Related