- 1package 验证登录信息是否合法;
- 2 3import java.util.Scanner;
- 4 5publicclass Login_Message_If_Legal {
- 6publicstaticvoid main(String[] args) {
- 7
- Scanner input=
- new Scanner(System.in);
- 8boolean
- loop=
- true;
- 9while(loop){
- 10
- System.out.println("Please enter your username:"
- );
- 11
- String Name=
- input.nextLine();
- 12if
- (Name.equals("sa"
- )){
- 1314
- }
- else{
- 15
- System.err.println("UserNaem is error,please again!"
- );
- 16continue;
- 17 }
- 18
- System.out.println("please your password:"
- );
- 19
- String password=
- input.nextLine();
- 20if
- (password.equals("1314"
- )){
- 2122
- }
- else{
- 23
- System.err.println("password is error,please again!"
- );
- 24continue;
- 25 }
- 26
- loop=
- false;
- 27
- System.out.println("login successful!"
- );
- 28 }
- 29 }
- 30
- }
来源: http://www.bubuko.com/infodetail-2150653.html