java - How to pass parameter in Stream.map method -
what below statement mean:
string joined = elements.stream() .map(object::tostring) .collect(collectors.joining(", "));
as understand, stream.map
accepts parameter of type function
. don't understand how object::tostring
being passed , how works?
thanks.
how
object::tostring
being passed , how works?
it called method reference in telling use existing tostring
method definition (from object
class) map
method, rather explicitly calling obj -> obj.tostring()
inside map
method.
i suggest @ here , understand on how method references work in java8.
Comments
Post a Comment