zoukankan      html  css  js  c++  java
  • 1、向集合添加元素是否能成功。。。

     1 package com.hanqi;
     2 
     3 import java.util.ArrayList;
     4 import java.util.Collections;
     5 import java.util.HashSet;
     6 import java.util.List;
     7 import java.util.TreeSet;
     8 
     9 public class JKL {
    10 
    11         ArrayList<String> lis = new ArrayList<String>();
    12         lis.add("A");
    13         lis.add("a");
    14         lis.add("c");
    15         lis.add("C");
    16         lis.add("a");
    17         Collections.addAll(lis, "e", "f", "g", "h", "i");
    18 
    19         System.out.println("ArrayList输出 " + lis);
    20 
    21         HashSet<String> hs = new HashSet<String>();
    22         
    23         hs.add("A");
    24         hs.add("a");
    25         hs.add("c");
    26         hs.add("C");
    27         hs.add("a");
    28 
    29         Collections.addAll(hs, "e", "f", "g", "h", "i");
    30 
    31         System.out.println("HashSet输出 " + hs);
    32 
    33         TreeSet<String> ss = new TreeSet<String>();
    34         
    35         ss.add("A");
    36         ss.add("a");
    37         ss.add("c");
    38         ss.add("C");
    39         ss.add("a");
    40         
    41         Collections.addAll(ss, "e", "f", "g", "h", "i");// 可以重复,有序大写在前,小写在后,以顺序排列
    42         
    43         System.out.println("TreeSet输出 " + ss);
    44 
    45 }
    46 }    

    HashSet输出 [f, g, e, c, A, C, a, h, i]
    TreeSet输出 [A, C, a, c, e, f, g, h, i]

  • 相关阅读:
    阿里云自定义镜像保存规则
    linux常用命令
    SQL
    redis集群
    AOP中的通知
    mysql8.0无法给用户授权或提示You are not allowed to create a user with GRANT的问题
    ---Linux命令
    feign
    spring clud / dubbo
    Ajax嵌套问题
  • 原文地址:https://www.cnblogs.com/as1234as/p/5152815.html
Copyright © 2011-2022 走看看