zoukankan      html  css  js  c++  java
  • map里的keyset()和entryset()方法.

    public class KeysetAndEntrySet {
        public static void main(String[] args) {
            Map map1 = new HashMap();
            Map map2  =  new TreeMap();
            
            map1.put("name1", "Christ Bosh");
            map1.put("name2","Kobe Bryant");
            map1.put("name3", "Lebron James");
            map1.put("name4", "Dwany Wade");
            
            map2.put("name1", "Christ Bosh");
            map2.put("name2","Kobe Bryant");
            map2.put("name3", "Lebron James");
            map2.put("name4", "Dwany Wade");
            
            Set set =  map1.entrySet();
            Iterator it = set.iterator();
            while(it.hasNext()){
                Map.Entry next = (Entry) it.next();
    //            System.out.println("========"+next.toString()+"**********");
    //            String str = it.next().toString();
    //            int index = str.indexOf("=");
    //            System.out.println(str.substring(0,index)+" "+str.substring(index+1));
                Object key = next.getKey();
                Object value = next.getValue();
                System.out.println(key+"++++"+value);
            }
            System.out.println("------------------------------------");
            Set set2  = map2.keySet();
            Iterator it2 = set2.iterator();
            while(it2.hasNext()){
                Object ob = it2.next();
                System.out.println(ob.toString()+" "+map2.get(ob));
            }
        }
    }

  • 相关阅读:
    APP上线碰到的问题:Non-public API usage
    点语法
    strlen、strcpy、strcat的实现
    2. I/O模型基本说明
    1. 同步、异步、阻塞、非阻塞
    8. 负载均衡请求转发实现
    7.负载均衡算法
    6. Nginx配置示例-高可用集群
    5. Nginx配置示例-动静分离
    4. Nginx配置示例-负载均衡
  • 原文地址:https://www.cnblogs.com/olvo/p/2501293.html
Copyright © 2011-2022 走看看