当前位置:网站首页>guava 教程收集一些案例慢慢写 google工具类
guava 教程收集一些案例慢慢写 google工具类
2022-06-27 06:50:00 【玲珑·】
参考
实现目标
- 了解Lists Sets Maps 等集合类的常用方法
- 了解guava Collections2 和 jdk Collections hutool CollectionUtil
- 了解guava ListenableFuture的 及 Java 原生Future的使用
问题
- 如何获得集合类的迭代器
- Collections 为什么搞那么多的内部类(为了返回类对象)
集合类
// map 拷贝
@Test
public void test4() throws IllegalAccessException {
HashMap<String, String> hashMap = Maps.newHashMap();
hashMap.put("1","A");
hashMap.put("2","B");
Map<String, String> res ;
res = ImmutableMap.copyOf(hashMap);
System.out.println(JSON.toJSONString(res));
}
集合类的初始化
// 普通Collection的创建
List<String> list = Lists.newArrayList();
Set<String> set = Sets.newHashSet();
Map<String, String> map = Maps.newHashMap();
// 不变Collection的创建
ImmutableList<String> iList = ImmutableList.of("a", "b", "c");
ImmutableSet<String> iSet = ImmutableSet.of("e1", "e2");
ImmutableMap<String, String> iMap = ImmutableMap.of("k1", "v1", "k2", "v2");
边栏推荐
- Classical cryptosystem -- substitution and replacement
- 【毕业季】毕业是人生旅途的新开始,你准备好了吗
- 记一次Spark报错:Failed to allocate a page (67108864 bytes), try again.
- Assembly language - Wang Shuang Chapter 11 flag register - Notes
- matlab GUI界面仿真直流电机和交流电机转速仿真
- Partial function of Scala
- Unsafe中的park和unpark
- How torch.gather works
- pytorch Default process group is not initialized
- 第 299 场周赛 第四题 6103. 从树中删除边的最小分数
猜你喜欢

2022 cisp-pte (II) SQL injection

The fourth question of the 299th weekly match 6103 Minimum fraction of edges removed from the tree

Fast implementation of thread mesh networking

SQL injection bypass (I)

Ahb2apb bridge design (2) -- Introduction to synchronous bridge design

Centos7.9安装mysql 5.7,并设置开机启动

vs怎么配置OpenCV?2022vs配置OpenCV详解(多图)

建模竞赛-光传送网建模与价值评估

Cloud-Native Database Systems at Alibaba: Opportunities and Challenges

POI replacing text and pictures in docx
随机推荐
Overview of database schema in tidb
Vs how to configure opencv? 2022vs configuration opencv details (multiple pictures)
小米面试官:听你说精通注册中心,我们来聊 3 天 3 夜
YOLOv6又快又准的目标检测框架 已开源
Caldera安装及简单使用
将通讯录功能设置为数据库维护,增加用户名和密码
Coggle 30 Days of ML 7月竞赛学习
OpenCV怎么下载?OpenCV下载后怎么配置?
winow10安装Nexus nexus-3.20.1-01
POI replacing text and pictures in docx
Get the query parameter in the address URL specify the parameter method
建模竞赛-光传送网建模与价值评估
IDEA连接数据库报错
HTAP in depth exploration Guide
2022 le fichier CISP - Pte (i) contient:
面试官:用分库分表如何做到永不迁移数据和避免热点问题?
一线大厂面试官问:你真的懂电商订单开发吗?
One year's experience of technical personnel in Entrepreneurship
2022 CISP-PTE(二)SQL注入
Park and unpark in unsafe