助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
## 3.4 collect操作 `collect`是一个**终端操作**,前面也多次用到,这一节会详细介绍collect的用法。Collectors类提供的工厂方法主要提供了三大功能: - 归约或汇总为一个值 - summingXxx:求和 - reducing:归约 - joining:连接字符串 - averaging:均值 - counting:计数 - min/maxBy:求最值 - 元素分组(group):按key值分组 - 元素分区(partition):按Boolean值分组 **代码清单12** 添加XX方法 `Xxx.java` <pre> // 在代码样式中嵌入样式,例如加粗表示增加的修改操作,删除线表示移除的修改操作 public static NoteFragment newInstance(UUID noteId) { Bundle args = new Bundle(); args.putSerializable(ARG_NOTE_ID, noteId); <b>NoteFragment noteFragment = new NoteFragment();</b> <del>noteFragment.setArguments(args);</del> return noteFragment; } </pre>