V
V
Viktor Potapov2015-12-16 10:15:32
Java
Viktor Potapov, 2015-12-16 10:15:32

How to reduce java 8 stream of objects to one element?

There is a stream of objects. For example:

public class Student implements Serializable {

    private long id;

    private String name;

    private String surname;

    private long group;

    // наши геттеры\сеттеры

}

And I need to overtake these objects from the stream into one object of another class, for example:
public class Student implements Serializable {

    private long id;

    private List<Student> students;

    private Student bestStudent;

    private long studentsCount;

   // наши геттеры\сеттеры

}

how to do it better? tried to deal with reduce and collect, but so far it has not been possible to achieve the desired.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question