Create list of object from another using Java 8 Streams

后端 未结 3 1644
星月不相逢
星月不相逢 2020-11-27 15:36

I\'m trying to understand Java 8 streams. I have two classes:

public class UserMeal {
    protected final LocalDateTime dateTime;

    protected final String         


        
3条回答
  •  抹茶落季
    2020-11-27 16:17

    What you are possibly looking for is map(). You can "convert" the objects in a stream to another by mapping this way:

    ...
     .map(userMeal -> new UserMealExceed(...))
    ...
    

提交回复
热议问题