This question already has an answer here:
- How do I compare strings in Java? 23 answers
When I type the same password (jalalkay) it gives me "False" answer!
import java.util.Scanner;
public class password2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner pass = new Scanner(System.in);
System.out.println("Type a password");
String ps = pass.nextLine();
if(ps == "jalalkay"){
System.out.println("true");
}else{
System.out.println("false");
}
}
}
Aucun commentaire:
Enregistrer un commentaire