What is the meaning of :: in the following code?
Set set = people.stream()
.map(Person::getName)
.collect(Collectors.toCollection(TreeSet::new));
Answer
This is method reference. Added in Java 8.
TreeSet::new
refers to the default constructor of TreeSet
.
In general A::B
refers to method B
in class A
.
No comments:
Post a Comment