I have this simple method:
public void setComboBoxItems(List<User> users, List<Client> clients) {
for (User user : users) {
usersIds.addItem(user.getId());
}
for (Client client : clients) {
clientsIds.addItem(client.getId());
}
}
What it does is add items to 2 JComboBox , the items added are the IDs of the Users and Clients contained in the 2 lists named users-clients .
Is there a way to simplify this method, perhaps by calling users.forEach()
?
My goal was to have fewer lines of code and do it with lambda expressions, so what I did was use
.forEach
.Which does practically the same as the previous method.
Let's say you could have done something like this:
The same code as before but trying to save space but it's not what I'm looking for since my goal is to learn and make use of lambda expressions.