Say I have a collection of users:

```
List<User> users = ...;

```

Now I want to get all the id's for the users in a list, currently I am doing:

```
for(User user : users) {
  userIds.add(user.getId());
}

```

Is there a more elegant way of doing this?

I know java doesnt' support linq, so maybe this is the only way but just thought I'd ask.