zoukankan      html  css  js  c++  java
  • 删除数组中的重复元素

    方案1:

    用set也很容易的
     
    1. public static void main(String[] args) {  
    2.        int[] nums = { 5666887 };  
    3.        List<Integer> numList = new ArrayList<Integer>();  
    4.        for (int i : nums)  
    5.            numList.add(i);  
    6.        Set<Integer> numSet = new HashSet<Integer>();  
    7.        numSet.addAll(numList);  
    8.        System.out.println(numSet);  
    9.    }  
     

    方案2:

    [java] 
    1. public static void main(String[] args) {  
    2.         String[] s = {"1","10","15","14","111","133","12","13","1","13"};  
    3.         List<String> l = new ArrayList<String>();  
    4.         for(String a:s){  
    5.             if(!l.contains(a)){  
    6.                 l.add(a);  
    7.             }  
    8.         }  
    9.         System.out.println(l);  
    10.     }  
  • 相关阅读:
    ZendFramwork配置
    JS控制页面前进、后退
    PHP乱码
    php 文件和表单内容一起上传
    mysqli常用命令
    图解SQL多表关联查询
    mysql默认字符集修改
    mysql控制台命令
    Nanami's Digital Board

  • 原文地址:https://www.cnblogs.com/allenzhaox/p/3201792.html
Copyright © 2011-2022 走看看