how to write code in java this statm if

public  String pass (){
        b =txt_pass.getText(); 
        if ("ameer".equals(b)) 
            JOptionPane.showMessageDialog(null, "the password is correct");
        return b;
         }

how to make this

 **if (user ()) retrun a **
 JOptionPane.showMessageDialog(null, "the password is correct");

How about returning a boolean?

// pseudo-code!
public boolean passwordIsOK() {
    get the password
    if (the password is correct) return true;
    else return false;
}

then you can say

if (passwordIsOK()) ... do whatever

or, simplified:

get the password;
return (if the password is correct);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.