day19/src/main/java/com/bwie/student/service/impl/StudentServiceImpl.java

51 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.bwie.student.service.impl;
import com.bwie.student.Student;
import com.bwie.student.service.StudentService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* @Authorweiran
* @Packagecom.bwie.student.service.impl
* @Projectweek3
* @nameStudentServiceImpl
* @Date2024/8/8 8:39
*/
@Service
public class StudentServiceImpl implements StudentService {
@Override
public List<Student> out() {
return null;
}
public static void main(String[] args) {
//创建5名学生(Student)对像,并放入集合中
ArrayList<Student> students = new ArrayList<>();
Student student1 = new Student(0, "张三", "语文", 78.0);
Student student2 = new Student(0, "李四", "语文", 88.0);
Student student3 = new Student(0, "王五", "语文", 79.0);
Student student4 = new Student(0, "赵六", "语文", 83.0);
Student student5 = new Student(0, "田七", "语文", 87.0);
students.add(student1);
students.add(student2);
students.add(student3);
students.add(student4);
students.add(student5);
Double avg=null;
for (Student student : students) {
avg+=student.getScore();
System.out.println("姓名为:"+student.getName()+"\n");
}
System.out.println("平均值为:"+(avg/5));
}
}