jeudi 24 décembre 2015

JOptionPane and ifelse statement

I am new in java, I want the dialog box show welcome when type "rauf", else it will show bye bye... how can i do it.

package book;
import javax.swing.JOptionPane;

public class dialog {

    public static void main(String[] args) {


        String name  = JOptionPane.showInputDialog("Please enter your name");


        if (name == "rauf" ){
            JOptionPane.showMessageDialog(null, "Welcome to PC");
            }
        else{
            JOptionPane.showMessageDialog(null, "bye!!!!!bye");
        }   
        System.exit(0);
        }
}

Aucun commentaire:

Enregistrer un commentaire