Lonely Integer

  • + 0 comments
        Map<Integer, Long> testMap =a.stream()
        .collect(Collectors.groupingBy(Function.identity()
            ,HashMap::new,
             Collectors.counting()));
        return testMap.entrySet().stream().filter(es -> es.getValue().intValue()==1)
        .map(tm -> tm.getKey()).findFirst().orElse(null);