Collectors in Java
- Belongs to
java.util.Stream.Collectors
- Helps in Accumulating or copying the data from
Stream
Object toCollection
Object . (Collections framework as in List ,Set) - Summarizing or performing operatiosn based on some criteria.
List<Integer> l=new ArrayList(); l.add(10); l.add(20); l.add(30); l.add(40); List l2=l.stream().map(i->i*i).collect(Collectors.toList());
- Used along with Java Streams