开发者社区> 问答> 正文

JAVA中Commons Collections - Inclusion如何理解?

JAVA中Commons Collections - Inclusion如何理解?

展开
收起
vncamyi27xznk 2021-11-13 23:53:12 336 0
1 条回答
写回答
取消 提交回答
  • "检查列表是否是另一个列表的一部分: console.log(import java.util.Arrays; import java.util.List; import org.apache.commons.collections4.CollectionUtils; public class CollectionUtilsTester { public static void main(String[] args) { //checking inclusion List<String> list1 = Arrays.asList(""A"",""A"",""A"",""C"",""B"",""B""); List<String> list2 = Arrays.asList(""A"",""A"",""B"",""B""); System.out.println(""List 1: "" + list1); System.out.println(""List 2: "" + list2); System.out.println(""Is List 2 contained in List 1: "" + CollectionUtils.isSubCollection(list2, list1)); } })

    它将打印以下结果: console.log(List 1: [A, A, A, C, B, B] List 2: [A, A, B, B] Is List 2 contained in List 1: true)

    资料来源:《Java工程师成神之路(基础篇)》,链接:https://developer.aliyun.com/topic/download?id=923"

    2021-11-16 15:41:52
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载