title: Concatenate two or more optional string in Java 8
body: <p>I have a rather simple question for you guys. In Java 8 it was introduced the <code>Optional</code> type. I have two objects of type <code>Optional&lt;String&gt;</code> and I want to know which is the more elegant way to concatenate them.</p>
  
  <pre><code>Optional&lt;String&gt; first = Optional.ofNullable(/* Some string */);
  Optional&lt;String&gt; second = Optional.ofNullable(/* Some other string */);
  Optional&lt;String&gt; result = /* Some fancy function that concats first and second */;
  </code></pre>
  
  <p>In detail, if one of the two original <code>Optional&lt;String&gt;</code> objects was equal to <code>Optional.empty()</code>, I want the whole concatenation to be empty too.</p>
  
  <p>Please, note that I am not asking how to concatenate the evaluation of two <code>Optional</code>s in Java, but how to concatenate two <code>String</code>s that are inside some <code>Optional</code>.</p>
  
  <p>Thanks in advance.</p>