League has 20 Team, team has 11 Player, player has int score field.
class Player {
private int score;
public int getScore() {
return score;
}
}
class Team {
private List<Player> players;
public List<Player> getPlayers() {
return players;
}
}
class League {
private List<Team> teams;
public List<Team> getTeams() {
return teams;
}
}
Need to select from List<Team> best Player with highest score and return one List<Player> including one best player from each team using Stream.
public List<Player> getTopPlayersFromEachTeam(List<Team> league) {
// implementation
}
Stuck at:
league.stream().map(Team::getPlayers).collect(Collectors.toList())
Any hints?