I came across this statement while going through JSR-335 specifications:
(test ? list.map(String::length) : Collections.emptyList())::iterator
What does this list.map(String::length) mean?
The map operation lets you apply a function, in this case, String::length to each argument in the list, and returns another collection comprised of the results of applying that function to each one of those list elements. In this case, a list of Integers.
Lets say I have a list that looks like:
{"Bob", "Mary", "Joe"}
then you'd get back:
{3, 4, 3}
after applying your particular mapping.
I believe that's a reference to the length methods defined in java.lang.String. In this case, you're basically telling .map() to call the method on every member of the collection and return a new collection comprised of those lengths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With