源代码:
public static void main(String[] args) {
// TODO 自动生成的方法存根
List<String> list = new ArrayList<>();
Scanner in = new Scanner(System.in);
for(int e=1;e>0;) {
System.out.println("输入需要的功能:\n1.输入汉字。\n2.查询文字。\n3.删除文字。\n4.退出");
int a=in.nextInt();
switch (a) {
case 1:{System.out.println("输入数字999即可退出。");
System.out.println("请输入汉字:");
for(int i=1;i>0;) {
String b=in.next();
if(b.equals("999")) {
System.out.println("退出成功!");
i=0;
}
else {
list.add(b);
System.out.println("输入成功该数的编号为"+list.size());
}
}break;
}
case 2:{
System.out.println("输入文字编号查询:\n输入0退出");
for(int b=1;b>0;) {
int c=in.nextInt();
if(c==0){
System.out.println("退出成功!");
b=0;
}
else {
System.out.println("该数对应的汉字为:"+list.get((c-1)));
}
}break;
}
case 3:{
System.out.println("输入文字编号即可删除:\n输入0退出");
for(int b=1;b>0;) {
int c=in.nextInt();
if(c==0){
System.out.println("退出成功!");
b=0;
}
else {
System.out.println("删除成功");
list.remove((c-1));
}
}break;
}
case 4:{
System.out.println("退出成功");
e=0;
}
}
}
}
吾独矣
终极愿望世界和平