zoukankan      html  css  js  c++  java
  • 两种方法删除ArrayList里反复元素

    方法一:

    /** List order not maintained **/
    
      public static void removeDuplicate(ArrayList arlList)
      {
       HashSet h = new HashSet(arlList);
       arlList.clear();
       arlList.addAll(h);
      }
    
    
    方法二:


    /** List order maintained **/
    
    public static void removeDuplicateWithOrder(ArrayList arlList)
     {
     Set set = new HashSet();
     List newList = new ArrayList();
     for (Iterator iter = arlList.iterator();    iter.hasNext(); ) {
     Object element = iter.next();
       if (set.add(element))
          newList.add(element);
        }
        arlList.clear();
        arlList.addAll(newList);
    }
    


查看全文
  • 相关阅读:
    There is no session with id session多人使用一个账号
    记录一次@Autowire和@Resource遇到的坑
    shiro 未认证登录统一处理以及碰到的问题记录
    Realm [*] was unable to find account data for the submitted AuthenticationToken
    springboot项目监听器不起作用
    发送邮件com.sun.mail.util.TraceInputStream.<init>(Ljava/io/InputStream;Lcom/sun/mail
    mysql查询重复数据记录
    使用shiro在网关层解决过滤url
    maven添加jetty插件,同时运行多个实例
    Linux 安装Zookeeper集群
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10925017.html
  • Copyright © 2011-2022 走看看