Java - pass key-value params into function with shortest syntax
<p>I want to pass list of key-values pairs into my function.</p>

<p>I can do this by following:</p>

<pre><code>HashMap&lt;String, String&gt; params = new HashMap&lt;&gt;();
params.put("param1", value1);
params.put("param2", value2);
foo(params);
</code></pre>

<p>But there are 4 lines of code. And my <code>foo</code> function will be called in many times in my code, so it becomes hard to read.</p>

<p>Can we decrease number of lines in this call?</p>

<ol>
<li>Is there a way to write <code>foo([("param1", value1), ("param2", value2)])</code>?</li>
<li>Maybe Java standard classes have constructors to pass there several elements?</li>
<li>Or can we write some factory class, that will create HashMap in less lines of code?</li>
</ol>