zoukankan      html  css  js  c++  java
  • JAVA-2.2-homework

    package Ac;
    
    import java.util.*;
    
    public class Test {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            show();
        }
        public static void show() {
        Map a = new HashMap();
        a.put("欧欧","Q仔");
        a.put("亚亚","Q妹");
        a.put("菲菲","Q妹");
        a.put("美美","Q妹");
        System.out.println("共计有"+a.size()+"只企鹅");
        Set keys = a.keySet();
        Iterator it = keys.iterator();    
        System.out.println("分别是:");
       while (it.hasNext()) {
           String key = (String)it.next();
           String b = (String) a.get(key);
           System.out.println(key+"	"+b);
        }
        }
    }
    package Ac;
    
    import java.util.*;
    
    public class Test {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            show();
        }
        public static void show() {
            Map<String,String> a = new HashMap<String,String>();
            a.put("欧欧","Q仔");
            a.put("亚亚","Q妹");
            a.put("菲菲","Q妹");
            a.put("美美","Q妹");
            System.out.println("共计有"+a.size()+"只企鹅");
            System.out.println("iterator输出");
            //iterator输出
            Set<String> keys = a.keySet();
            Iterator<String> it = keys.iterator();    
            System.out.println("分别是:");
            while (it.hasNext()) {
                String key = (String)it.next();
                String b = (String) a.get(key);
                System.out.println(key+"	"+b);
            }
            System.out.println("foreach语句输出");
            //foreach语句输出
            for (String key : keys) {
                String b = a.get(key);
                System.out.println(key+"	"+b);
            }
        }
    }
  • 相关阅读:
    noip2016组合数问题
    noip2017奶酪
    洛谷1091合唱队形
    洛谷P1075 质因数分解
    洛谷1004方格取数
    POJ2393奶酪工厂
    NOIP2012国王游戏(60分题解)
    洛谷1106删数问题
    洛谷1209修理牛棚
    二维树状数组区间修改+区间查询模版
  • 原文地址:https://www.cnblogs.com/yunlan/p/13100013.html
Copyright © 2011-2022 走看看