LinkedHashMap和HashMap的区别以及使用方法
来源:互联网 发布:python获取当天日期 编辑:程序博客网 时间:2024/05/29 19:59
Map<String String> map = Collections.synchronizedMap(new LinkedHashMap(<String String));
import Java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
public class TestLinkedHashMap {
public static void main(String args[])
{
System.out.println("*************************LinkedHashMap*************");
Map<Integer,String> map = new LinkedHashMap<Integer,String>();
map.put(6, "apple");
map.put(3, "banana");
map.put(2,"pear");
for (Iterator it = map.keySet().iterator();it.hasNext();)
{
Object key = it.next();
System.out.println( key+"="+ map.get(key));
}
System.out.println("*************************HashMap*************");
Map<Integer,String> map1 = new HashMap<Integer,String>();
map1.put(6, "apple");
map1.put(3, "banana");
map1.put(2,"pear");
for (Iterator it = map1.keySet().iterator();it.hasNext();)
{
Object key = it.next();
System.out.println( key+"="+ map1.get(key));
}
}
}
运行结果如下:
*************************LinkedHashMap*************
6=apple
3=banana
2=pear
*************************HashMap**************************
2=pear
6=apple
3=banana
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap和HashMap的区别以及使用方法
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap 和 HashMap的区别
- LinkedHashMap和HashMap的区别
- HashMap和LinkedHashMap的区别
- HashMap和LinkedHashMap的区别
- 使用cmake编译protobuf生成vs2010工程
- iOS https请求对自签名证书忽略
- 如何通过iMindMap摆脱夏天低迷的状态
- 自定义PopupWindow并且设置背景色变暗的2种方法(蒙层效果)
- ClipDrawable资源之徐徐展开的风景
- LinkedHashMap和HashMap的区别以及使用方法
- Activity 生命周期与启动模式
- Oracle group up函数与rollup的使用说明
- Synchronized的用法
- ios下iframe内的加载更多为什么失效了?
- android开发中,可能会导致内存泄露的问题
- 【Unity】 C# 协程 WaitForSeconds产生GC(Garbage Collection)问题
- ssh的前世今生
- JD-Eclipse 安装