package com.zhuzhuxia.demo;1
2
import com.alibaba.fastjson.JSON;
3
import com.alibaba.fastjson.JSONArray;
4
import com.google.common.collect.Lists;
5
import org.junit.jupiter.api.Test;
6
7
import java.util.Comparator;
8
import java.util.List;
9
import java.util.Map;
10
import java.util.stream.Collectors;
11
12
/**
13
* @Author: 猪猪侠
14
* @Date: 2019/10/30 17:59
15
* @Version: 1.0
16
* @Description:
17
*/
18
public class MyTest {
19
20
@Test
21
public void listTest(){
22
List<Integer> integerList = Lists.newArrayList(1, 2, 3, 4, 5, 6,
3, 5, 1, 4, 2, 8, 9);
23
List<Student> studentList = Lists.newArrayList();
24
Student stu1 = new Student(1L,"张三",15);
25
Student stu2 = new Student(2L,"李四",11);
26
Student stu3 = new Student(3L,"王五",12);
27
Student stu4 = new Student(4L,"赵六",10);
28
studentList.add(stu1);
29
studentList.add(stu2);
30
studentList.add(stu3);
31
studentList.add(stu4);
32
System.out.println("学生原数据:"+JSONArray.toJSON(studentList));
33
System.out.println("----------------------------------------------
-------");
34
35
36
List<Student> collect1 = studentList.stream().filter(stu ->
stu.getName().equals("张三")).collect(Collectors.toList());
37
System.out.println("查出姓名是“张三”的学
生:"+JSONArray.toJSON(collect1));
38
评论0
最新资源