使用HashMap打印字符串
来源:互联网 发布:redhat和ubuntu的区别 编辑:程序博客网 时间:2024/05/21 07:34
HashMap<String, String> hashMap=new HashMap<>();//声明hashMap对象
hashMap.put("name", "tom");//hashMap添加字符串
hashMap.put("height", "177");//hashMap添加字符串
hashMap.put("age", "12");//hashMap添加字符串
Iterator<Entry<String, String>> iterator=hashMap.entrySet().iterator();//创建iterator对象
while(iterator.hasNext()){//用while循环,判断是否有下一个
Entry<String, String> entry=iterator.next();//声明entry,并用它来装载字符串
System.out.println("key="+entry.getKey()+"valve="+entry.getValue());//调用getKey()和getValue()打印
hashMap.put("name", "tom");//hashMap添加字符串
hashMap.put("height", "177");//hashMap添加字符串
hashMap.put("age", "12");//hashMap添加字符串
Iterator<Entry<String, String>> iterator=hashMap.entrySet().iterator();//创建iterator对象
while(iterator.hasNext()){//用while循环,判断是否有下一个
Entry<String, String> entry=iterator.next();//声明entry,并用它来装载字符串
System.out.println("key="+entry.getKey()+"valve="+entry.getValue());//调用getKey()和getValue()打印
}
输出结果:
key=namevalve=tom
key=agevalve=12
key=heightvalve=177
0 0
- 使用HashMap打印字符串
- 使用DbgPrint打印字符串和其他
- 打印字符串
- HashMap打印结果困惑 java
- HashMap使用
- 使用HashMap
- HashMap使用
- HashMap使用
- hashmap 使用
- 直接使用默认设置进行打印:(2)使用MFC编程实现打印中文字符串
- 直接使用默认设置进行打印:(3)使用VC开发ActiveX控件实现打印中文字符串
- 使用std流打印16进制字符串示例
- 使用循环的方式打印字符串所有排列组合
- 使用xargs循环查找文件中的字符串并打印出来
- 遍历JSON字符串转为HashMap
- hashmap对字符串的统计
- [os] 打印字符串
- Linux打印不同颜色字符串
- 挥泪告别巡视组,袁萌不是问题人
- 【测试缺陷报告】
- C++ Iterator设计模式的思考 (Boolan学习笔记第13周)
- 学习新的计算机语言的方法
- matlab导入工具箱方法以及遇到问题的解决
- 使用HashMap打印字符串
- 《疯狂JAVA讲义》之八——java标识符规则和关键字
- ImportError: No module named _tkinter
- MacOS下安装RVM无法安装公钥的解决办法
- hdu 2852 (求某个序列第k大的值,可以任意删除其中的元素和添加元素)
- Anroid软件自动扫描拍照识别名片SDK
- C++结构体
- Github全面详解-04Github社交
- VMware 12 安装Ubuntu 16.04 (图文教程)