I'm working on if statement on java but I keep on getting cannot find symbol error
I know the mistake is "input.nextString();" but when I get rid of the string and leave it as input.next(); & input the userid and password it gives me the false output Admin Login Password is incorrect!, not the true output Admin User Logged In, how can I fix it?
import java.util.Scanner; public class Login {
public static void main(String args[]) {
Scanner input = new Scanner(System.in); // input scanner
// Prompt the user to enter userid and password
String userid = "admin";
String password = "ctc";
System.out.println("Enter your userid:");
userid = input.nextString();
System.out.println("Enter your password:");
password = input.nextString();
if(userid == ("admin") && (password == ("ctc"))){
System.out.println("Admin User Logged In");
}
else {
System.out.println("Admin Login Password is incorrect!");
}
}
}
Aucun commentaire:
Enregistrer un commentaire