Код: Выделить всё
class Foo {
private int variableCount;
public Foo(int vars) {
this.variableCount = vars;
}
public Integer getVariableCount() {
return variableCount;
}
}
Пример
date:
Код: Выделить всё
new Foo(3), new Foo(3), new Foo(2), new Foo(1), new Foo(1)
< /code>
Я хочу, чтобы поток вернул последние 2 foo < /code> s, поскольку они имеют наименьшее значение..collect(Collectors.groupingBy((Foo foo) -> {
return foo.getVariableCount();
})
Подробнее здесь: https://stackoverflow.com/questions/490 ... m-api-with