Classical set operations for java.util.Collection

前端 未结 4 1089
情歌与酒
情歌与酒 2020-11-28 04:43

Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like s

4条回答
  •  一向
    一向 (楼主)
    2020-11-28 05:16

    Are you looking for java.util.Set interface (and its implementations HashSet and TreeSet (sorted))?
    The interface defines removeAll(Collection c) which looks like substract(), and retainAll(Collection c) which looks like intersection.

提交回复
热议问题