java.util.Map

五迷三道 提交于 2020-04-03 10:20:09

map时key/value形式存储信息的,键可以为对象null

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("hello", "world");
        map.put(null, "HelloWorld");
        System.out.println(map);
        System.out.println(map.get(null));
        
        System.out.println("-----");
        for (String key : map.keySet()) {
            System.out.println(key+":"+map.get(key));
        }
    }

结果输出:

在http的响应中状态栏的key 就是 对象null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!