zoukankan      html  css  js  c++  java
  • 10.16

    package jhe;
    
    import java.util.*;
    
    public class jihetext {
    
        public static void main(String[] args) {
            
            ArrayList<Object> al1 = new ArrayList<>();
            
            al1.add("sdad");
            
            
            List<String> al = new ArrayList<>();
            
            al.add("abc");
            
            System.out.println("集合大小"+ al.size());
            
            al.add("def");
            
            al.clear();//清除
            
            al.isEmpty();
            
            System.out.println("是不是空的 = "+ al.isEmpty());
    
            //System.out.println("集合大小"+ al.size());
            
            //System.out.println("集合内容"+ al.get(0));
            
            for (int i = 0;i< 10;i++)
            {
                al.add(String.format("%s", (Math.random()*1000)));
            }
            
            System.out.println();
            
            for (int a = 0;a <= 100;a++)
            {
                al.add("" + a);
            }
            
            al.remove(10);
            
            for(int b = 0; b < al.size();b++)
            {
                System.out.println("剩余集合内容"+ al.get(b));
            }
            //指定索引移除
            al.remove(0);
            
            al.set(0, "新的值");
            
            for (int i = 0; i < al.size(); i++)
            {
                System.out.println("集合内容" + al.get(i));
            }
            
            LinkedList<String> ll = new LinkedList<>();
            
            for (int i = 10;i> 0;i--)
            {
                ll.add("" + i);
                //al.add(String.format("%s", (Math.random()*1000)));
            }
            
            ll.add("10");
        
            for (int i = 0; i < ll.size(); i++)
            {
                System.out.println("集合内容" + ll.get(i));
            }
            
            HashSet<String>hs = new HashSet<>();
            
            hs.add("abc");
            
            hs.add("abc");
            
            for (int i = 10;i > 0;i--)
            {
                hs.add("" + i);
                //al.add(String.format("%s", (Math.random()*1000)));
            }
            
            //hs.add();
            //迭代器
            
            Iterator<String> ls = hs.iterator();
            
            while (ls.hasNext())
            {
                System.out.println("迭代 = " + ls.next());
            }
            
            TreeSet<String> ts = new TreeSet<>();
            
            ts.add("abc");
            
            for (int i = 20; i > 0; i--)
            {
                ts.add("" + i);
            }
            
            System.out.println("first = " + ts.first() + " last = " + ts.last());
            
            Iterator<String> is = ts.iterator();
            
            while(is.hasNext())
            {
                System.out.println("treeSet = " + is.next());
            }
            
            //
            for(String s : ts)
            {
                System.out.println("foreach = " + s);
            }
            
            
            //哈希Map
            HashMap<String, String> hm = new HashMap<>();
            
            hm.put("255000", "淄博");
            
            hm.put("234000", "东京热");
            
            hm.put("121000", "西京冷");
            
            
            
            System.out.println("25500对应得城市是"+hm.get("255000"));
            
            System.out.println("是否包含110000= " + hm.containsKey(234000));
  • 相关阅读:
    读TIJ -2 一切都是对象
    codeforces 437C The Child and Toy
    关于js基础easy忘记的那些事儿
    项目启动会应该注意的几点
    SSH-Struts(一)——基本原理
    公益代理-开发人员的福音
    【手打】LZW编码的C/C++实现
    tab group of firefox
    Sort Colors -- LeetCode
    Qt 学习之路:自定义事件
  • 原文地址:https://www.cnblogs.com/zhuxiaolin/p/4886668.html
Copyright © 2011-2022 走看看