Kotlin Map methods – maxBy() maxWith()

In the tutorial, JavaSampleApproach will show how to use Kotlin Map methods maxBy(), maxWith().

I. Kotlin Map methods – maxBy() maxWith()

1. maxBy()

maxBy() returns the first entry having largest value of the given function selector: (Map.Entry) -> R or ‘null’ if there are no elements.
Method signature:

Practice:

2. maxWith()

maxWith() returns the first entry having the largest value according to the provided [comparator]
Method signature:

Practice:

II. Full Sourcecode

By JavaSampleApproach | January 11, 2018.

Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*