日考19
commit
9aa14b8810
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>day19</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>2.6.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,31 @@
|
|||
package com.bwie.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class Student {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer stuId;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String stuName;
|
||||
/**
|
||||
* 科目
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
private String score;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.bwie.test;
|
||||
|
||||
import com.bwie.domain.Student;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
//1.创建5名学生(Student)对象(编号,姓名,科目,分数)。
|
||||
Student student = new Student(1,"lina","数学","139");
|
||||
Student student1 = new Student(2,"Nancy","化学","60");
|
||||
Student student2 = new Student(3,"Lucy","语文","125");
|
||||
Student student3 = new Student(4,"Lucky","英语","148");
|
||||
Student student4 = new Student(5,"Baby","地理","29");
|
||||
|
||||
//2.将所有学生拼接字符串放入集合中,如:1,张三,语文,100 2,张三,数学,90
|
||||
ArrayList<Student> students = new ArrayList<>();
|
||||
students.forEach(student5 -> {
|
||||
System.out.println(students);
|
||||
});
|
||||
|
||||
//3.使用stream操作集合并输出每个人的名字及其平均成绩。
|
||||
|
||||
System.out.println(student.getStuName());
|
||||
System.out.println(student.getScore());
|
||||
|
||||
System.out.println(student1.getStuName());
|
||||
System.out.println(student1.getScore());
|
||||
|
||||
System.out.println(student2.getStuName());
|
||||
System.out.println(student2.getScore());
|
||||
|
||||
System.out.println(student3.getStuName());
|
||||
System.out.println(student3.getScore());
|
||||
|
||||
System.out.println(student4.getStuName());
|
||||
System.out.println(student4.getScore());
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
artifactId=day19
|
||||
groupId=com.bwie
|
||||
version=1.0-SNAPSHOT
|
|
@ -0,0 +1,3 @@
|
|||
com\bwie\domain\Student$StudentBuilder.class
|
||||
com\bwie\domain\Student.class
|
||||
com\bwie\test\Test.class
|
|
@ -0,0 +1,2 @@
|
|||
D:\Users\Dell\Desktop\专高六资料\day19\src\main\java\com\bwie\domain\Student.java
|
||||
D:\Users\Dell\Desktop\专高六资料\day19\src\main\java\com\bwie\test\Test.java
|
Loading…
Reference in New Issue