当前位置:网站首页>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");
边栏推荐
- Fast realization of Bluetooth communication between MCU and mobile phone
- Interviewer: how to never migrate data and avoid hot issues by using sub database and sub table?
- 数据库系统工程师对口专业有哪些?
- ORA-00909: 参数个数无效,concat引起
- Spark sql 常用时间函数
- oracle的similarity方法实现原理
- SQL考勤查询间隔一小时
- POI replacing text and pictures in docx
- Park and unpark in unsafe
- 从5秒优化到1秒,系统飞起来了...
猜你喜欢
随机推荐
Visual Studio VS 快捷键使用大全
C Primer Plus Chapter 11_ Strings and string functions_ Codes and exercises
Ora-00909: invalid number of parameters, caused by concat
记一次Spark报错:Failed to allocate a page (67108864 bytes), try again.
win10远程连接云服务器
如何优雅的写 Controller 层代码?
tracepoint
extendible hashing
Nature、science、cell旗下刊物
Ahb2apb bridge design (2) -- Introduction to synchronous bridge design
matlab GUI界面仿真直流电机和交流电机转速仿真
Centos7.9安装mysql 5.7,并设置开机启动
poi导出excle
An Empirical Evaluation of In-Memory Multi-Version Concurrency Control
SQL考勤查询间隔一小时
Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights
进程终止(你真的学会递归了吗?考验你的递归基础)
YOLOv6又快又准的目标检测框架 已开源
建模竞赛-光传送网建模与价值评估
Solve the problem of win10 wsl2 IP change









