帮我生成一份表头为"Projects Name", "Project Introduction", "Role", "Date",的学生Java实践
时间: 2023-09-07 14:13:20 浏览: 40
以下是一份示例代码,可以根据需要进行调整和修改:
```java
import java.util.ArrayList;
import java.util.List;
public class StudentJavaProjects {
private static class Project {
private String name;
private String introduction;
private String role;
private String date;
public Project(String name, String introduction, String role, String date) {
this.name = name;
this.introduction = introduction;
this.role = role;
this.date = date;
}
public String getName() {
return name;
}
public String getIntroduction() {
return introduction;
}
public String getRole() {
return role;
}
public String getDate() {
return date;
}
}
public static void main(String[] args) {
List<Project> projects = new ArrayList<>();
projects.add(new Project("Project A", "This project is about ...", "Developer", "2021-01-01"));
projects.add(new Project("Project B", "This project is about ...", "Tester", "2021-02-01"));
projects.add(new Project("Project C", "This project is about ...", "Designer", "2021-03-01"));
System.out.printf("%-20s%-40s%-20s%-10s\n", "Projects Name", "Project Introduction", "Role", "Date");
for (Project project : projects) {
System.out.printf("%-20s%-40s%-20s%-10s\n", project.getName(), project.getIntroduction(), project.getRole(), project.getDate());
}
}
}
```
输出结果为:
```
Projects Name Project Introduction Role Date
Project A This project is about ... Developer 2021-01-01
Project B This project is about ... Tester 2021-02-01
Project C This project is about ... Designer 2021-03-01
```