zoukankan      html  css  js  c++  java
  • java,map集合

    package org.hanqi.array;
    import java.util.*;
    
    public class Test3 {
    
        public static void main(String[] args) {
            // TODO 自动生成的方法存根
            Map<String,String> m=new HashMap<String,String>();
            m.put("0533", "淄博");
            m.put("0531","济南" );
            m.put("0532","青岛" );
            System.out.println("长度="+m.size());
            //m.put("0532","黄岛");
            System.out.println("长度="+m.size());
            m.put("0534", "青岛");
            m.put(null, null);
            System.out.println("长度="+m.size());
            //根据Key获取value
            System.out.println("0533="+m.get("0533"));
            //Key是否存在
            if(m.containsKey("0533"))
            {
                System.out.println("Key 0533已存在");
            }
            //value是否存在
            if(m.containsValue("淄博"))
            {
                System.out.println("淄博已存在");
            }
            //遍历
            for(String k:m.keySet())
            {
                System.out.println(k+"="+m.get(k));
            }
        
    
        }
    
    }

  • 相关阅读:
    c# 字符串中某个词出现的次数及索引
    c# 冒泡排序
    WCF 高级知识
    Web Api基础知识
    Web Services基础知识
    WCF Demo
    IIS部署WCF常见错误
    IIS部署WCF
    IIS部署WCF错误
    WCF基础知识
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5265893.html
Copyright © 2011-2022 走看看