List<Map<String,String>> 根据某一个属性去重

List> listMap = new ArrayList<>();
        List> list = vehicleMapper.findCarModel();
        Set keysSet = new HashSet();
        for(Map collisionMap : list){
            String keys = String.valueOf(collisionMap.get("name"));
            int beforeSize = keysSet.size();
            keysSet.add(keys);
            int afterSize = keysSet.size();
            if(afterSize == beforeSize + 1){
                listMap.add(collisionMap);
            }
        }

 

你可能感兴趣的:(编程技术,java,java)