In Java7 I have this code:
public int getPlayersOnline() { int count = 0; for (Player player : players) { if (player.isActive()) {
This would be a one-liner:
return (int) players.stream().filter(Player::isActive).count();