展开全部
e68a8462616964757a686964616f31333335326133Scanner scan = new Scanner(System.in);
String name = "";
String rname = "";
String nname = "";
List nameList = new ArrayList();
System.out.println("请输入客户名称:");
nameList.add(scan.next());
System.out.println("继续输入吗?(y/n)");
while (true) {
if ("y".equals(scan.next())) {
System.out.println("请输入客户名称:");
nameList.add(scan.next());
} else {
System.out.println("客户姓名列表");
for (String names : nameList) {
System.out.println(names);
}
System.out.println("请输入要修改的客户名称:");
rname = scan.next();
System.out.println("请输入新的客户名称:");
nname = scan.next();
for (int i = 0; i < nameList.size(); i++) {
if (rname.equals(nameList.get(i))) {
nameList.remove(i);
nameList.add(nname);
}
}
System.out.println("新的客户姓名列表");
for (String names : nameList) {
System.out.println(names);
}
}
System.out.println("继续输入吗?(y/n)");
}