直接上代码
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
public class Jdk8 {
public static void main(String[] args) {
List<Student> list = new ArrayList<Student>();
list.add(new Student(33, "aaa", "chuangye"));
list.add(new Student(25, "bbb", "chuangye"));
list.add(new Student(9, "ccc", "chuangye"));
list.add(new Student(11, "ddd", "chuangye"));
//简单遍历
// list.stream().forEach(stu -> {
// //此处是对遍历出来的对象进行操作
// System.out.println(JSONObject.toJSONString(stu));
//
// //输出结果
// /**
// * {"address":"chuangye","age":3,"name":"aaa"}
// * {"address":"chuangye"