import java.util.Scanner; public class miMa { String account = "mi"; String password = "123456"; public void accountInfo() { System.out.println("账号:" + account + "\t密码:" + password); } public static void main(String[] args) { miMa mi = new miMa(); System.out.println("未修改密码之前的账号信息--------"); mi.accountInfo(); Scanner sc = new Scanner(System.in); while (true) { System.out.println("请输入账号名称:"); String accountName = sc.next(); System.out.println("请输入密码:"); String pwd = sc.next(); if (accountName.equals(mi.account) && pwd.equals(mi.password)) { System.out.println("您输入的账号信息有误,请重新输入!"); } System.out.println("修改密码之后的账户信息--------"); mi.accountInfo(); } } }