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

Popular posts from this blog

Java Swing Complete examples step by step(make a project with swing)

Java Program to find average of Three numbers

Java Program any letter to upper case Letter(JavaSWING) ActionListener