zoukankan      html  css  js  c++  java
  • 课本235页2-3题

    package org.hanqi.array;
    
    import java.util.*;
    
    public class Xiti2 {
    
        public static void main(String[] args) {
            List<String> list=new ArrayList<String>();
            list.add("A");
            list.add("a");
            list.add("c");
            list.add("C");
            list.add("a");
            for(String s:list)
            {
                System.out.println(s);
            }
            System.out.println("集合长度="+list.size());
            System.out.println("List集合成功添加");
            
            
            HashSet<String>s1=new HashSet<String>();
            s1.add("A");
            s1.add("a");
            s1.add("c");
            s1.add("C");
            s1.add("a");
            for(String t:s1)
            {
                System.out.println(t);
            }
            System.out.println("集合长度="+s1.size());
            System.out.println("Set集合不能成功添加");
    
        }
    
    }
    View Code

    package org.hanqi.array;
    
    import java.util.HashMap;
    import java.util.Map;
    
    public class Emp {
    
        private String key;
        private String value;
        public Emp(String key,String value)
        {
            this.key=key;
            this.value=value;
        }
        public String getKey() {
            return key;
        }
        public void setKey(String key) {
            this.key = key;
        }
        public String getValue() {
            return value;
        }
        public void setValue(String value) {
            this.value = value;
        }
        public static void main(String[] args)
        {
            Map<String, String>m=new HashMap<String, String>();
            Emp emp=new Emp("001","德州扒鸡");
            Emp emp2=new Emp("002","北京烤鸭");
            Emp emp3=new Emp("003","绝味鸭头");
            Emp emp4=new Emp("004","博山酥锅");
            Emp emp5=new Emp("005","武汉热干面");
            Emp emp6=new Emp("006","周村烧饼");
            Emp emp7=new Emp("007","淄博烧烤");
            
            
            m.put(emp.getKey(), emp.getValue());
            m.put(emp2.getKey(), emp2.getValue());
            m.put(emp3.getKey(), emp3.getValue());
            m.put(emp4.getKey(), emp4.getValue());
            m.put(emp5.getKey(), emp5.getValue());
            m.put(emp6.getKey(), emp6.getValue());
            m.put(emp7.getKey(), emp7.getValue());
            
            m.remove(emp5);
            for(String t:m.keySet())
            {
                if(t=="005")
                {
                    m.remove(emp5);
                }
                else
                {
                    System.out.println(t);
                }
            }
        }
    
    }
    View Code

  • 相关阅读:
    在github上面查到了,为什么需要这个padding
    Java 8 新语法习惯,新的函数特性和语法
    数据库连接池配置,获取连接的超时
    用函数式的方式思考,通常以命令式的方式
    centos7 yum方式安装,centos自带mariadb
    mac屏幕脏了怎么办?避免使用粗糙的布
    用 Arthas “庖丁解牛,强大的 Arthas法师来 carry
    图解Knative核心组件,Serving自动伸缩
    vim配置文件
    20200717模拟赛3题解
  • 原文地址:https://www.cnblogs.com/panyiquan/p/5267729.html
Copyright © 2011-2022 走看看