commit 71046e9b83954b7999df6d718548be6ffdc32d7e Author: 张腾 <3467447354@qq.com> Date: Thu Aug 8 09:11:49 2024 +0800 8.8 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..6560a98 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5d79e0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..67ca509 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/zg6-day19/com/bwie/list/Demo01.class b/out/production/zg6-day19/com/bwie/list/Demo01.class new file mode 100644 index 0000000..c927cc7 Binary files /dev/null and b/out/production/zg6-day19/com/bwie/list/Demo01.class differ diff --git a/out/production/zg6-day19/com/bwie/pojo/Student.class b/out/production/zg6-day19/com/bwie/pojo/Student.class new file mode 100644 index 0000000..b3fec07 Binary files /dev/null and b/out/production/zg6-day19/com/bwie/pojo/Student.class differ diff --git a/src/com/bwie/list/Demo01.java b/src/com/bwie/list/Demo01.java new file mode 100644 index 0000000..699fa3b --- /dev/null +++ b/src/com/bwie/list/Demo01.java @@ -0,0 +1,31 @@ +package com.bwie.list; + +import com.bwie.pojo.Student; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author:张腾 + * @Package:com.bwie.list + * @Project:zg6-day19 + * @name:Demo01 + * @Date:2024/8/8 8:38 + */ +public class Demo01 { + + public static void main(String[] args) { + List list = new ArrayList<>(); + list.add(new Student(1,"张三","语文",89.5)); + list.add(new Student(2,"张三","数学",90.0)); + list.add(new Student(3,"李四","语文",88.5)); + list.add(new Student(4,"李四","数学",68.0)); + list.add(new Student(5,"王五","语文",78.0)); + list.add(new Student(6,"王五","数学",98.0)); + list.stream() + .collect(Collectors.groupingBy(Student::getName, + Collectors.averagingDouble(Student::getScore))) + .forEach((stu,score) -> System.out.println("姓名:"+stu+"平均分:"+score)); + } +} diff --git a/src/com/bwie/pojo/Student.java b/src/com/bwie/pojo/Student.java new file mode 100644 index 0000000..99afb08 --- /dev/null +++ b/src/com/bwie/pojo/Student.java @@ -0,0 +1,66 @@ +package com.bwie.pojo; + +/** + * @Author:张腾 + * @Package:com.bwie.pojo + * @Project:zg6-day19 + * @name:Student + * @Date:2024/8/8 8:39 + */ +public class Student { + + private Integer id; + private String name; + private String socket; + private Double score; + + public Student(Integer id, String name, String socket, Double score) { + this.id = id; + this.name = name; + this.socket = socket; + this.score = score; + } + + @Override + public String toString() { + return "编号:" + id + + ", 姓名:" + name + '\'' + + ", 科目:" + socket + '\'' + + ", 分数:" + score; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSocket() { + return socket; + } + + public void setSocket(String socket) { + this.socket = socket; + } + + public Double getScore() { + return score; + } + + public void setScore(Double score) { + this.score = score; + } + + public Student() { + } +} diff --git a/zg6-day19.iml b/zg6-day19.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/zg6-day19.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file