A simple method using string to check whether the input password is correct or not
package String;
import java.util.Scanner;
public class EquilityTest {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter the password");
String pass=sc.nextLine();
String password="bikas";
if(pass.equals(password)) {
System.out.println("Right password");
}else if(pass.equalsIgnoreCase(password)) {
System.out.println("right Password");
}else if(pass.isEmpty()) {
System.out.println("Cannot be empty");
}else if(pass.isBlank()) {
System.out.println("Dont leave it blank");
}
sc.close();
}
}
Comments
Post a Comment