Subtracting one arrayList from another arrayList

后端 未结 9 881
无人及你
无人及你 2021-01-01 11:00

I have two arrayLists and I am trying to \"subtract\" one arrayList from another. For example, if I have one arrayList [1,2,3] and I am trying to subtract [0, 2, 4] the resu

9条回答
  •  迷失自我
    2021-01-01 12:01

    Try to use subtract method of org.apache.commons.collections.CollectionUtils class.

    Returns a new Collection containing a - b. The cardinality of each element e in the returned Collection will be the cardinality of e in a minus the cardinality of e in b, or zero, whichever is greater.

    CollectionUtils.subtract(java.util.Collection a, java.util.Collection b) 
    

    From Apache Commons Collections

提交回复
热议问题