title: Java 8 Lambdas Pass Function or Variable as a Parameter
body: <p>I am new to Java 8 lambdas. I have a code starts with:</p>
  
  <pre><code>StringBuilder lemma = new StringBuilder("(");
  </code></pre>
  
  <p>and than two pieces of codes. First one:</p>
  
  <pre><code>lemma.append("(");
  
  for (String dt : dts) {
     lemma.append("label1:").append(labelList.getLabel1(dt)).append(OPERATOR);
   }
  
  lemma.delete(lemma.length() - OPERATOR.length(), lemma.length());
  lemma.append(")");
  </code></pre>
  
  <p>Second one:</p>
  
  <pre><code>lemma.append("(");
  
  for (String mt : mts) {
     lemma.append("label2:").append(mt).append(OPERATOR);
   }
  
  lemma.delete(lemma.length() - OPERATOR.length(), lemma.length());
  lemma.append(")");
  </code></pre>
  
  <p>How can I make a function which covers that 2 pieces of code which accepts arguments:</p>
  
  <pre><code>List&lt;String&gt; (which is for -dts- or -mts-)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>String (which is for -"label1:"- or -"label2:"-)   
  </code></pre>
  
  <p>and</p>
  
  <pre><code>func() (which is for -labelList.getLabel1(dt)- or -mt-)
  </code></pre>
  
  <p>Is it possible to do such a thing with Java 8 lambdas?</p>