package ch07.admin;
/**
* Created by liwenj on 2017/7/19.
*/
文件1;
public class adminclass {
String name;
String password;
public void show(){
System.out.println("姓名:"+name);
System.out.println("密码"+password);
}
}
文件2;
public class admin {
public static void main(String[] args) {
adminclass adminclass1 = new adminclass();
adminclass1.name = "张三";
adminclass1.password = "123456";
Scanner input = new Scanner(System.in);
System.out.println("输入姓名");
String nm = input.next();
System.out.println("输入密码");
String ps = input.next();
if (nm.equals(adminclass1.name) && ps.equals(adminclass1.password)) {
System.out.println("可以更改密码,输入新密码:");
adminclass1.password = input.next();
System.out.println("修改后的密码是:" + adminclass1.password);
} else {
System.out.println("输入错误,没有权限");
}
}
}