• 去掉集合中的重复元素


     1 //去掉集合中额重复元素
     2 //方法:选择排序的思想
     3 
     4 public class ArrayListDemo1 {
     5 
     6     public static void main(String[] args) {
     7 
     8         ArrayList arrayList = new ArrayList();
     9 
    10         arrayList.add("hello");
    11         arrayList.add("hello");
    12         arrayList.add("java");
    13         arrayList.add("world"); 
    14         arrayList.add("android");
    15         arrayList.add("javase");
    16         arrayList.add("javaee");
    17 
    18         // Iterator it = arrayList.iterator();
    19         for (int i = 0; i < arrayList.size() - 1; i++) {
    20             for (int j = i + 1; j < arrayList.size(); j++) {
    21                 if (arrayList.get(i).equals(arrayList.get(j))) {
    22                     arrayList.remove(j);
    23                     j--;//假如有连续重复的元素,删除后补位,有漏网之鱼
    24                   }
    25 
    26             }
    27 
    28         }
    29 
    30     }
    31 
    32 }
  • 相关阅读:
    RLP
    Merkle Patricia Tree (MPT) 树详解
    Patricia Tree
    Merkle Tree学习
    mongodb 范围查找
    mongodb _id 组成
    mongodb 时间戳转_id
    mongdi db _id 转时间戳
    js中的filter
    js中的filter
  • 原文地址:https://www.cnblogs.com/AllenIverson/p/4556206.html
Copyright © 2020-2023  润新知