【发布时间】:2016-12-27 10:43:28
【问题描述】:
假设我有以下课程:
public class Foo {
private int id;
private String name;
public int getId() {
return id;
}
public Foo setId(int id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public Foo setName(String name) {
this.name = name;
return this;
}
}
然后,我在Collection<Foo> fooCollection 中有几个Foo 对象和字符串数组String[] names。
现在我想通过属性name 订购fooCollection,以相同的顺序排列name 字符串在names 中订购。
如何使用 Java 8 Stream 做到这一点?
【问题讨论】:
-
这如何涉及
names数组?
标签: sorting java-8 java-stream