zoukankan      html  css  js  c++  java
  • 【去除集合中字符串的重复值-2】

    package com.yjf.esupplier.common.test;
    
    import java.util.ArrayList;
    import java.util.Iterator;
    
    /**
     * @author shusheng
     * @description 去除集合中字符串的重复值(字符串的内容相同)
     * @Email shusheng@yiji.com
     * @date 2018/12/12 16:55
     */
    public class ArrayListDemo1 {
    
        public static void main(String[] args) {
            ArrayList array = new ArrayList();
            array.add("hello");
            array.add("world");
            array.add("world");
            array.add("world");
            array.add("java");
            array.add("java");
            array.add("hello");
            array.add("hello");
            array.add("software");
    
            for(int x=0;x<array.size()-1;x++){
                for(int y=x+1;y<array.size();y++){
                    if(array.get(x).equals(array.get(y))){
                        array.remove(y);
                        y--;
                    }
                }
            }
    
            Iterator it = array.iterator();
            while(it.hasNext()){
                System.out.println(it.next());
            }
    
        }
    
    }
    终身学习者
  • 相关阅读:
    leetcode 34 rust
    leetcode 2 rust
    leetcode 1 rust
    leetcode 20 rust
    leetcode 287 rust
    leetcode 18 rust
    lottery抽奖
    webpack
    webpack(7)-生产环境
    webpack(6)-模块热替代&tree shaking
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/10340839.html
Copyright © 2011-2022 走看看