<div dir="ltr"><div>Not sure if it is the right mail list, please advise if there is a better place to give suggestions about Java language.</div><div><br></div><div>I suggest using lamba-like syntax for method implementation. Suppose you have a code like this:</div><div><br></div><div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(0,51,179)">final class </span><span style="color:rgb(0,0,0)">Account </span>{<br>    <span style="color:rgb(0,51,179)">private final int </span><span style="color:rgb(135,16,148)">id</span>;<br>    <span style="color:rgb(0,51,179)">private </span><span style="color:rgb(0,0,0)">String </span><span style="color:rgb(135,16,148)">name</span>;<br><br>    <span style="color:rgb(0,51,179)">public </span><span style="color:rgb(0,98,122)">Account</span>(<span style="color:rgb(0,51,179)">int </span>id) {<br>        <span style="color:rgb(0,51,179)">this</span>.<span style="color:rgb(135,16,148)">id </span>= id;<br>    }<br><br>    <span style="color:rgb(0,51,179)">public int </span><span style="color:rgb(0,98,122)">getId</span>() {<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(135,16,148)">id</span>;<br>    }<br><br>    <span style="color:rgb(0,51,179)">public </span><span style="color:rgb(0,0,0)">String </span><span style="color:rgb(0,98,122)">getName</span>() {<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(135,16,148)">name</span>;<br>    }<br><br>    <span style="color:rgb(0,51,179)">public </span><span style="color:rgb(0,51,179)"></span><span style="color:rgb(0,98,122)">Account</span><span style="color:rgb(0,51,179)"> </span><span style="color:rgb(0,98,122)">setName</span>(<span style="color:rgb(0,0,0)">String </span>name) {<br>        <span style="color:rgb(0,51,179)">this</span>.<span style="color:rgb(135,16,148)">name </span>= name;</div>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(0,51,179)">this</span>;<br>    }<div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><br>    <span style="color:rgb(158,136,13)">@Override<br></span><span style="color:rgb(158,136,13)">    </span><span style="color:rgb(0,51,179)">public </span><span style="color:rgb(0,0,0)">String </span><span style="color:rgb(0,98,122)">toString</span>() {<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(6,125,23)">"Account{id=" </span>+ <span style="color:rgb(135,16,148)">id </span>+ <span style="color:rgb(6,125,23)">", name='" </span>+ <span style="color:rgb(135,16,148)">name </span>+ <span style="color:rgb(6,125,23)">'</span><span style="color:rgb(0,55,166)">\'</span><span style="color:rgb(6,125,23)">' </span>+ <span style="color:rgb(6,125,23)">'}'</span>;<br>    }<br><br>    <span style="color:rgb(158,136,13)">@Override<br></span><span style="color:rgb(158,136,13)">    </span><span style="color:rgb(0,51,179)">public boolean </span><span style="color:rgb(0,98,122)">equals</span>(<span style="color:rgb(0,0,0)">Object </span>o) {<br>        <span style="color:rgb(0,51,179)">if </span>(<span style="color:rgb(0,51,179)">this </span>== o) <span style="color:rgb(0,51,179)">return true</span>;<br>        <span style="color:rgb(0,51,179)">if </span>(o == <span style="color:rgb(0,51,179)">null </span>|| getClass() != o.getClass()) <span style="color:rgb(0,51,179)">return false</span>;<br>        <span style="color:rgb(0,0,0)">Account account </span>= (<span style="color:rgb(0,0,0)">Account</span>) o;<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(135,16,148)">id </span>== <span style="color:rgb(0,0,0)">account</span>.<span style="color:rgb(135,16,148)">id</span>;<br>    }<br><br>    <span style="color:rgb(158,136,13)">@Override<br></span><span style="color:rgb(158,136,13)">    </span><span style="color:rgb(0,51,179)">public int </span><span style="color:rgb(0,98,122)">hashCode</span>() {<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(0,0,0)">Objects</span>.<span style="font-style:italic">hash</span>(<span style="color:rgb(135,16,148)">id</span>);<br>    }<br>}<br><br><span style="color:rgb(0,51,179)">void </span><span style="color:rgb(0,98,122)">transfer</span>(<span style="color:rgb(0,0,0)">Account </span>from, <span style="color:rgb(0,0,0)">Account </span>to, <span style="color:rgb(0,51,179)">int </span>amount) {<br>    transfer(from, to, amount, <span style="color:rgb(23,80,235)">0</span>);<br>}<br><span style="color:rgb(0,51,179)">void </span><span style="color:rgb(0,98,122)">transfer</span>(<span style="color:rgb(0,0,0)">Account </span>from, <span style="color:rgb(0,0,0)">Account </span>to, <span style="color:rgb(0,51,179)">int </span>amount, <span style="color:rgb(0,51,179)">int </span>commission) {<br>    <span style="color:rgb(0,0,0)">System</span>.<span style="color:rgb(135,16,148);font-style:italic">out</span>.printf(<span style="color:rgb(6,125,23)">"Transferred %s -> %s %s (commission: %s)"</span>, from, to, amount, commission);<br>}<br></div></div></div><div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(0,51,179)">void </span><span style="color:rgb(0,98,122)">main</span>() {</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(140,140,140);font-style:italic">//there is no way to see here which one is "</span><span style="color:rgb(0,0,0)"></span>from<span style="color:rgb(140,140,140);font-style:italic">" which one is "</span><span style="color:rgb(0,0,0)"></span>to<span style="color:rgb(140,140,140);font-style:italic">". Where is the </span><span style="color:rgb(0,51,179)"></span>amount<span style="color:rgb(140,140,140);font-style:italic">, where is the </span><span style="color:rgb(0,51,179)"></span>commission<span style="color:rgb(140,140,140);font-style:italic">?</span></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">    transfer(<span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">1</span>), <span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">2</span>), <span style="color:rgb(23,80,235)">100</span>);<br>    transfer(<span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">2</span>), <span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">1</span>), <span style="color:rgb(23,80,235)">200</span>, <span style="color:rgb(23,80,235)">5</span>);</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">}</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><br></div></div><div>The lambda syntax allows reducing boiler-plate code  significantly and new possibilities like named parameters and default parameter values. And it is syntactic sugar, just applying the same rules which are used for lambdas instead of usual method definitions. Like this:</div><div><br></div><div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(0,51,179)">final class </span><span style="color:rgb(0,0,0)">Account </span>{<br>    <span style="color:rgb(0,51,179)">private final int </span><span style="color:rgb(135,16,148)">id</span>;<br>    <span style="color:rgb(0,51,179)">private </span><span style="color:rgb(0,0,0)">String </span><span style="color:rgb(135,16,148)">name</span>;<br><br>    <span style="color:rgb(0,98,122)">Account</span>(<span style="color:rgb(0,51,179)">int </span>id) -> <span style="color:rgb(0,51,179)">this</span>.<span style="color:rgb(135,16,148)">id </span>= id;<br><br>    <span style="color:rgb(0,98,122)">getId</span>() -> <span style="color:rgb(135,16,148)">id</span>;<br><br>    <span style="color:rgb(0,98,122)">getName</span>() -> <span style="color:rgb(135,16,148)">name</span>;<br><br>    <span style="color:rgb(0,98,122)">setName</span>(<span style="color:rgb(0,0,0)">String </span>name) -> {<span style="color:rgb(0,51,179)"> this</span>.<span style="color:rgb(135,16,148)">name </span>= name; <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(0,51,179)">this</span>; }<br><br>    <span style="color:rgb(0,98,122)">toString</span>() -> <span style="color:rgb(6,125,23)">"Account{id=" </span>+ <span style="color:rgb(135,16,148)">id </span>+ <span style="color:rgb(6,125,23)">", name='" </span>+ <span style="color:rgb(135,16,148)">name </span>+ <span style="color:rgb(6,125,23)">'</span><span style="color:rgb(0,55,166)">\'</span><span style="color:rgb(6,125,23)">' </span>+ <span style="color:rgb(6,125,23)">'}'</span>;<br><br>    <span style="color:rgb(0,98,122)">equals</span>(o) -> {<br>        <span style="color:rgb(0,51,179)">if </span>(<span style="color:rgb(0,51,179)">this </span>== o) <span style="color:rgb(0,51,179)">return true</span>;<br>        <span style="color:rgb(0,51,179)">if </span>(o == <span style="color:rgb(0,51,179)">null </span>|| getClass() != o.getClass()) <span style="color:rgb(0,51,179)">return false</span>;<br>        <span style="color:rgb(0,0,0)">Account account </span>= (<span style="color:rgb(0,0,0)">Account</span>) o;<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(135,16,148)">id </span>== <span style="color:rgb(0,0,0)">account</span>.<span style="color:rgb(135,16,148)">id</span>;<br>    }<br></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><br></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">    <span style="color:rgb(0,98,122)">hashCode</span>() -> <span style="color:rgb(0,0,0)">Objects</span>.<span style="font-style:italic">hash</span>(<span style="color:rgb(135,16,148)">id</span>);<br>}<br></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><br></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(0,51,179)">interface </span><span style="color:rgb(0,0,0)">TransferParams </span>{</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(140,140,140);font-style:italic">//required params with compile-time guarantee</span></div></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">    <span style="color:rgb(0,0,0)">Account </span><span style="color:rgb(0,98,122)">from</span>();<br>    <span style="color:rgb(0,0,0)">Account </span><span style="color:rgb(0,98,122)">to</span>();<br>    <span style="color:rgb(0,51,179)">int </span><span style="color:rgb(0,98,122)">amount</span>();</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(140,140,140);font-style:italic">//optional param with mandatory default</span></div>    <span style="color:rgb(0,51,179)">default </span><span style="color:rgb(0,98,122)">commission</span>() -> <span style="color:rgb(0,51,179)"></span><span style="color:rgb(0,98,122)">amount</span>() / <span style="color:rgb(23,80,235)">2</span><span style="color:rgb(23,80,235)">0</span>; </div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(140,140,140);font-style:italic">// desugared "</span><i><span style="color:rgb(0,51,179)">default int </span><span style="color:rgb(0,98,122)">commission</span>() {<span style="color:rgb(0,51,179)">return </span>amount() / <span style="color:rgb(23,80,235)">10</span>;}<span style="color:rgb(140,140,140)">"</span></i></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">}<br></div><br><span style="color:rgb(0,51,179)">void </span><span style="color:rgb(0,98,122)">transfer</span>(<span style="color:rgb(0,51,179)"></span><span style="color:rgb(0,0,0)">TransferParams p</span>) {<br>    <span style="color:rgb(0,0,0)">System</span>.<span style="color:rgb(135,16,148);font-style:italic">out</span>.printf(<span style="color:rgb(6,125,23)">"Transferred %s -> %s %s (commission: %s)"</span>, p.from(), <a href="http://p.to">p.to</a>(), p.amount(), p.commission());<br>}<br></div></div><div><div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(0,51,179)"><br></span></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(0,51,179)">void </span><span style="color:rgb(0,98,122)">main</span>() {</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(140,140,140);font-style:italic">//this is very similar to single-method interface like <a class="gmail_plusreply" id="plusReplyChip-0">@FunctionalInterface </a>but for multiple methods hence it's using a "named" lambdas</span></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">    transfer({from() -> <span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">1</span>); to() -> <span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">2</span>); amount() -> <span style="color:rgb(23,80,235)">100</span>;});<br>    transfer({from() -> <span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">2</span>); to() -> <span style="color:rgb(0,51,179)">new </span>Account(<span style="color:rgb(23,80,235)">1</span>); amount() -> <span style="color:rgb(23,80,235)">200</span>; commission() -> <span style="color:rgb(23,80,235)">5</span>;});</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre">}</div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><span style="color:rgb(140,140,140);font-style:italic">//desugared would be something like that:</span></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><i>transfer(<span style="color:rgb(0,51,179)">new </span><span style="color:rgb(0,0,0)">TransferParams</span>() {<br>    <span style="color:rgb(158,136,13)">@Override </span><span style="color:rgb(0,51,179)">public </span><span style="color:rgb(0,0,0)">Account </span><span style="color:rgb(0,98,122)">from</span>() {<br>        <span style="color:rgb(0,51,179)">return new </span>Account(<span style="color:rgb(23,80,235)">1</span>);<br>    }<br><br>    <span style="color:rgb(158,136,13)">@Override </span><span style="color:rgb(0,51,179)">public </span><span style="color:rgb(0,0,0)">Account </span><span style="color:rgb(0,98,122)">to</span>() {<br>        <span style="color:rgb(0,51,179)">return new </span>Account(<span style="color:rgb(23,80,235)">2</span>);<br>    }<br><br>    <span style="color:rgb(158,136,13)">@Override </span><span style="color:rgb(0,51,179)">public int </span><span style="color:rgb(0,98,122)">amount</span>() {<br>        <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(23,80,235)">100</span>;<br>    }<br>});</i><br></div></div><div style="background-color:rgb(255,255,255);color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre"><br><br></div></div></div><div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">WBR, Anatoly.</div></div></div>