class Check{ public boolean validate(String userName , String password){ if(userName.equals("zb")&&password.equals("123456")) { return true ; }else{ return false ; } } } class Operate{ private String info[] ; public Operate(String info[]){ this.info = info ; } public String login(){ Check check = new Check() ; this.isExit() ; String str = null ; String userName = this.info[0] ; String password = this.info[1] ; if(check.validate(userName,password)){ str = "欢迎"+userName+"光临" ; } return str ; } public void isExit(){ if(this.info.length!=2){ System.out.println("输入的参数不正确,请重新输入!") ; System.out.println("输入格式:java LoginDemo02 zb 123456") ; System.exit(1) ; } } } class LoginDemo02{ public static void main(String []args){ Operate operate = new Operate(args) ; System.out.print(operate.login()) ; } }