A good lambda for array length?
<p>Is there an elegant lambda for an array length? Something like a method reference, just not for a method? Array <code>length</code> is more like a public final field.</p>

<p>From a jagged 2D array (<code>Object[][]</code>) I wanted to find the longest inner array. It’s easy enough:</p>

<pre><code>    OptionalInt width = Stream.of(myJaggedArray).mapToInt(line -&gt; line.length).max();
</code></pre>

<p>I’m just wondering if I’m missing something when I cannot find better than <code>line -&gt; line.length</code>. I had thought <code>Object[]::length</code> might work, but it gives “The type Object[] does not define length(Object[]) that is applicable here”. I have searched the web without finding an alternative.</p>

<p>I can live happily with what I have. Maybe it’s just a special thing for arrays caused by the length not coming from a method. Thought it was worth asking.</p>