zoukankan      html  css  js  c++  java
  • list采坑记录一下

    List<Integer> cards = Lists.newArrayList(6,10,11,12,21,23,29,30,38,39,42,43,46,51,53,59,60);
    List<Integer> copyList = Lists.newArrayList();
    copyList = cards;
    copyList.remove(2);
    System.out.println("cards:"+cards);
    System.out.println("copyList:"+copyList);


    用了等号的操作结果是

    cards:[6, 10, 12, 21, 23, 29, 30, 38, 39, 42, 43, 46, 51, 53, 59, 60]
    copyList:[6, 10, 12, 21, 23, 29, 30, 38, 39, 42, 43, 46, 51, 53, 59, 60]

    List<Integer> cards = Lists.newArrayList(6,10,11,12,21,23,29,30,38,39,42,43,46,51,53,59,60);
    List<Integer> copyList = Lists.newArrayList();
    copyList.addAll(cards);
    copyList.remove(2);
    System.out.println("cards:"+cards);
    System.out.println("copyList:"+copyList);


    用了add的结果

    cards:[6, 10, 11, 12, 21, 23, 29, 30, 38, 39, 42, 43, 46, 51, 53, 59, 60]
    copyList:[6, 10, 12, 21, 23, 29, 30, 38, 39, 42, 43, 46, 51, 53, 59, 60]

    用等号操作时两个集合都会被操作,add不会

  • 相关阅读:
    JVM 调优工具
    JVM tomcat 性能调优
    meven 新建web 项目
    垃圾收集器
    JVM 内存溢出
    JVM 常见参数配置
    垃圾回收机制策略
    MongoDB C#驱动:
    基于MSMQ绑定的WCF服务实现总结
    python _、__和__xx__的区别(转)
  • 原文地址:https://www.cnblogs.com/michaelcnblogs/p/11564438.html
Copyright © 2011-2022 走看看