lambda優雅取出list中某個字段重複的集合

    arrays.stream()
    .collect(Collectors.groupBy(a->a.getField(),Collectors.counting())
    .entrySet.stream()
    .filter(entry->entry.getValue()>1)
    .map(entry->entry.getKey())
    .collect(Collectors.toList());
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章