当前位置:编程学习 > JAVA >>

equals方法if语句验证用户密码

import java.util.Scanner; 
 
 
 
 
public class CheckLogin { 
    public static void main(String[]args) 
    { 
        Scanner scanner = new Scanner(System.in); 
        System.out.println("请输入登陆的用户名:"); 
        String usernameString = scanner.nextLine(); 
        System.out.println("请输入登陆的密码:"); 
        String passwordString = scanner.nextLine(); 
        if (!usernameString.equals("nihao")) { 
            System.out.println("用户名错误"); 
             
        } 
        else if (!passwordString.equals("123")) { 
            System.out.println("密码错误"); 
             
        } 
        else { 
            System.out.println("通过验证"); 
        } 
        } 
     
 
}
补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,