I have a list of instances where I need to create another list of instances using the instances in the first list. As the example shown below, I can use a foreach or a for loop. Is there a better way to do this more efficiently?
List<Mesage> messages;
List<ArchMessage> archMessages = new ArrayList<>();
for(Message message : messages) {
archMessages.add(new ArchMessage(message));
}
MessageandArcMessageclasses?ArchMessagemeans the archivedMessage.