jdk8 流式写法汇总
日积月累不放弃,总有柳暗花明。
一、准备对象
定义一个对象ChatGPT
/**
* ChatGPT
* <p>
*
* @author solin
* @version 1.0.0
* @date 2023/3/20
*/
public class ChatGPT {
private Long id;
private String name;
private Integer level;
private Date date;
private List<String> strList;
}
初始化数据
private static List<ChatGPT> initData(){
List<ChatGPT> chatList = new ArrayList<>();
ChatGPT chatGPT1 = new ChatGPT(1L, "solin1", 1, new Date(),Arrays.asList("a","b"));
ChatGPT chatGPT2 = new ChatGPT(2L, "solin2", 2, new Date(),Arrays.asList("a","c"));
ChatGPT chatGPT3 = new ChatGPT(3L, "solin3",