lambda Variable used in lambda expression should be final or effectively final

从标题错误来看是 lambada里面变量需要是final类型

所以我下面代码报错 了

lambda Variable used in lambda expression should be final or effectively final_第1张图片

 

使用数组传值 绕过这个规则

  days.parallelStream().forEach(n->{
            String timeKey = n.replaceAll("-","");
            //根据项目名称
            List catServiceNames = catService.getCatServiceNames();
            Integer[] totalVisitNumForThisTimekey = new Integer[]{0};

            catServiceNames.stream().forEach(p->{
                totalVisitNumForThisTimekey[0]+=CatVisitStorage.getDayData(timeKey).get(p)==null ? 0 :CatVisitStorage.getDayData(timeKey).get(p);
            });
            CatVisitStorage.setDayData(timeKey,"total", totalVisitNumForThisTimekey[0]);
        });

 

你可能感兴趣的:(j2se)