首页 > 编程语言 > 详细

009-java中常用的单个键值对

时间:2018-10-04 04:51:22      阅读:400      评论:0      收藏:0      [点我收藏+]

1、Java 6提供AbstractMap.SimpleEntry<K,V>和AbstractMap.SimpleImmutableEntry<K,V> 

Map.Entry<String,Integer> entry1 = new AbstractMap.SimpleEntry<String, Integer>("key", 9527);

2、Apache commons-collections的KeyValue 

Map.Entry<String,Integer> entry3 = new DefaultMapEntry("key", 9527)
KeyValue<String,Integer> kv = new DefaultKeyValue("rkey", 9527);

3、Guava的Maps.immutableEntry 

Map.Entry<String,Integer> entry2 = Maps.immutableEntry("key", 9527);

4、Apache commons-lang3的Pair 

Map.Entry<String,Integer> entry4 =new ImmutablePair<String,Integer>("key", 9527);

5、Apache HttpClient的NameValuePair 

NameValuePair nv = new BasicNameValuePair("key", "9527");

可以扩展Map.Entry或者封装Class。

 

009-java中常用的单个键值对

原文:https://www.cnblogs.com/bjlhx/p/9740062.html

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