The syntax of map method in java 8 is :
<R> Stream<R> map(Function<? super T,? extends R> mapper)
but i can use a lambda expression :
personList.stream().filter(p -> p.getPersonType().equals("student"))
.map(p -> new Student(p.getId(), p.getName()))
.collect(Collectors.toList());
How does the argument in map method equates to a Function datatype.Please help me understand this .
Thanks
Function<Person,Person> function = p -> new Student(p.getId(), p.getName())