首页 > 编程语言 > 详细

java中HashMap有什么用,举例说明?

时间:2021-07-14 10:33:13      阅读:21      评论:0      收藏:0      [点我收藏+]

3.8 HashMap的用法

马克-to-win:HashMap和HashSet很像,只不过它里面存的是一个一个的键值对。

例:3.8.1

import java.util.*;
public class TestMark_to_win {
    public static void main(String[] args) {
        Map<String, String> m = new HashMap<String, String>();
        m.put("zs", "333-6666");
        m.put("ls", "111-2222");
        m.put("wwMark", "444-7777");
        Iterator iter = m.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry e = (Map.Entry) iter.next();
            System.out.println(e.getKey() + " " + e.getValue());
        }
    }
}
 

 

更多内容请见原文,原文转载自:https://blog.csdn.net/qq_44639795/article/details/103087424

java中HashMap有什么用,举例说明?

原文:https://www.cnblogs.com/xiaolongxia1922/p/15009323.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!