1. 程式人生 > >去掉一個list中包含的另一個list資料,高效寫法

去掉一個list中包含的另一個list資料,高效寫法

            LinkedList<Question> veirfyingList = questionService.getVeirfying(cityCode);
            LinkedList<Question> verifiedList = questionService.getVerifiedQuestion(uid, cityCode);
            HashSet h1 = new HashSet(veirfyingList);
            HashSet h2 = new HashSet(verifiedList);
            h1.removeAll(h2);
            veirfyingList.clear();
            veirfyingList.addAll(h1);