Bandysol 2022-07-24 11:59 采纳率: 83.3%
浏览 79
已结题

如何删掉String数组中的值?

import java.util.*;

public class ruko {
    public static void main(String[] args) {

        Map <String,String>  map = new HashMap<>();
        map.put("I","我");
        map.put("am","是(第一人称)");
        map.put("aah","啊");
        map.put("hello","你好");
        map.put("hi","嗨");
        map.put("ooh","嗬");
        map.put("goodbye","再见");
        map.put("bye-bye","拜拜");
        map.put("are","是(第二人称)");
        map.put("good","好的");
        map.put("morning","上午");
        map.put("fine","健康");
        map.put("thank","谢谢");
        map.put("you","你,你们");
        map.put("Ms","女士");
        map.put("boy","男孩");
        map.put("girl","女孩");
        map.put("whoops","喔哟");
        map.put("and","和");
        map.put("too","也");
        map.put("haha","哈哈");
        map.put("what","什么");
        map.put("is","是(第三人称)");
        map.put("your","你的,你们的");
        map.put("name","名字");
        map.put("please","请");
        map.put("afternoon","下午");
        map.put("Mr","先生");
        map.put("point","指");
        map.put("to","向");
        map.put("the","这个,那个");
        map.put("door","门");
        map.put("sit","坐");
        map.put("down","下,向下");
        map.put("stand","站");
        map.put("up","上,向上");
        map.put("window","窗户");
        map.put("blackbord","黑板");
        map.put("bird","鸟");
        map.put("tweet","鸟叫声");
        map.put("desk","桌子");
        map.put("chair","椅子");
        map.put("it","它");
        map.put("red","红色");
        map.put("look","看");
        map.put("wow","哇");
        map.put("yellow","黄色");
        map.put("blue","蓝色");
        map.put("a","一个");
        map.put("chameleon","变色龙");
        map.put("my","我的");
        map.put("panda","熊猫");
        map.put("now","现在");
        map.put("green","绿色");
        map.put("black","黑色");
        map.put("dog","狗");
        map.put("cat","猫");
        map.put("cap","帽子");
        map.put("one","一");
        map.put("two","二");
        map.put("three","三");
        map.put("four","四");
        map.put("five","五");
        map.put("six","六");
        map.put("seven","七");
        map.put("eight","八");
        map.put("nine","九");
        map.put("oh","哦");
        map.put("ten","十");
        map.put("eleven","十一");
        map.put("twelve","十二");

        Scanner scan = new Scanner(System.in);
        Random rand = new Random();
        System.out.println("欢迎使用外研版英语单词记忆测评系统V0.1.0");
        System.out.println("‘1’为三年级上册");
        System.out.print("请输入:");
        String a = scan.next();
        int fan = 100;
        int go = 1;

        String[] tup1 = {"I","am","aah","hello","hi","ooh","goodbye","bye-bye","are","good","morning",
                "fine","thank","you","Ms","boy","girl","whoops","and","too","haha","what",
                "is","your","name","please","afternoon","Mr","point","to","the","door","sit",
                "down","stand","up","window","blackbord","bird","tweet","desk","chair","it",
                "red","look","wow","yellow","blue","a","chameleon","my","panda","now","green",
                "black","dog","cat","cap","one","two","three","four","five","six","seven",
                "eight","nine","oh","ten","eleven","twelve"};

        if (a.equals("1")) {
            for (;go <= 100;go += 1) {
                String n = tup1[(int) Math.floor(Math.random()*tup1.length)];
                Object c = map.get(n);
                System.out.print("请输入" + c + "的英语意思:");
                String b = scan.next();
                if (b.equals(n)) {
                    System.out.println("答对了!");
                } else {
                    System.out.println("答错了!");
                    System.out.println("正确答案是:" + n);
                    fan -= 1;
                    System.out.println("得分:" + fan);
                }
            }
            String[] tup2 = {"I","am","aah","hello","hi","ooh","goodbye","bye-bye","are","good","morning",
                    "fine","thank","you","Ms","boy","girl","whoops","and","too","haha","what",
                    "is","your","name","please","afternoon","Mr","point","to","the","door","sit",
                    "down","stand","up","window","blackbord","bird","tweet","desk","chair","it",
                    "red","look","wow","yellow","blue","a","chameleon","my","panda","now","green",
                    "black","dog","cat","cap","one","two","three","four","five","six","seven",
                    "eight","nine","oh","ten","eleven","twelve"};
        tup1 = tup2;
        }
        if (!a.equals("1") && !a.equals("2") && !a.equals("3") && !a.equals("4") && !a.equals("5") && !a.equals("6") && !a.equals("7") && !a.equals("8")) {
            System.out.println("错误!");
        }
    }
}

按这样出题会出现重复的题目,我就想删掉出过的题目在tup1数组中的值,出完题后将tup2数组中的内容插回tup1。
但是一直不知道怎么删掉。

  • 写回答

2条回答 默认 最新

  • 原来我不知道啊 2022-07-24 12:29
    关注

    可以考虑使用 List 来实现:

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月8日
  • 已采纳回答 7月31日
  • 创建了问题 7月24日

悬赏问题

  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,