Java 8 Streams : get non repeated counts

前端 未结 5 1850
南方客
南方客 2021-01-18 11:54

Here is the SQL version for the input and output :

     with tab1 as (

        select 1 as id from dual union all
        select 1 as id from dual union all         


        
5条回答
  •  误落风尘
    2021-01-18 12:37

    An alternative is to filter repeated elements out of the list but it's not very efficient so I would only use it if the list is small:

    List result = myList.stream()
                                 .filter(i -> Collections.frequency(myList, i) == 1)
                                 .collect(toList());
    

提交回复
热议问题