如何使用Java8使用两个列表准备第三个列表
我有两个不同的列表,使用它们,我准备使用流的第三个列表 Student.java如何使用Java8使用两个列表准备第三个列表,java,collections,Java,Collections,我有两个不同的列表,使用它们,我准备使用流的第三个列表 Student.java public class Student { int id; String name; public Student(int id, String name) { super(); this.id = id; this.name = name; } public int getId() { return i
public class Student {
int id;
String name;
public Student(int id, String name) {
super();
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
StudentLoc.java
public class StudentLoc {
int id;
String loc;
public StudentLoc(int id, String loc) {
super();
this.id = id;
this.loc = loc;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLoc() {
return loc;
}
public void setLoc(String loc) {
this.loc = loc;
}
}
我有下面的三等舱
StudentDetLoc.java
public class StudentDetLoc {
int id;
String name;
String Loc;
}
streams()
和map()
forEach()
作为步骤2的终止操作,并附加到最后的第三个列表(仅保留id
、name
和Loc
)李>
你能分享一下示例代码吗