驗證登錄信息是否合法
阿新 • • 發佈:2017-07-03
line string size logs mes sta nextline pre loop
1 package 驗證登錄信息是否合法;
2
3 import java.util.Scanner;
4
5 public class Login_Message_If_Legal {
6 public static void main(String[] args) {
7 Scanner input=new Scanner(System.in);
8 boolean loop=true;
9 while(loop){
10 System.out.println("Please enter your username:");
11 String Name=input.nextLine();
12 if(Name.equals("sa")){
13
14 }else{
15 System.err.println("UserNaem is error,please again!");
16 continue;
17 }
18 System.out.println("please your password:");
19 String password=input.nextLine();
20 if(password.equals("1314")){
21
22 }else{
23 System.err.println("password is error,please again!");
24 continue;
25 }
26 loop=false;
27 System.out.println("login successful!");
28 }
29 }
30 }
驗證登錄信息是否合法