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

  • 相关阅读:
    asp.net自带的异步刷新控件使用
    C#反射之创建对象实例
    用httpHandler实现简易ajax框架
    在配置文件中使用相对路径连接数据库文件
    C# 扩展方法
    JavaScript动态创建元素(老帖新发)
    为所有类型扩展一个深拷贝方法
    C#反射之获取程序集信息
    枚举类型的位运算
    SQL2005数据库还原到SQL2000的方法
  • 原文地址:https://www.cnblogs.com/panyiquan/p/5267729.html
Copyright © 2011-2022 走看看