title: How to create an immutable list from another list and separate items?
body: <p>I am given a list and I want to add a single element of the same type that the list holds</p>
  
  <pre><code>List&lt;String&gt; list = List.of("a", "b", "c");
  String item = "d";
  </code></pre>
  
  <p>I want to create an immutable list from both of them</p>
  
  <pre><code>List&lt;String&gt; combined = List.of(list.toArray(new String[0]), item);
  </code></pre>
  
  <p>The above of course does not compile because it's looking at the 2 argument overload where one argument is a String[] and the other is a String and want to create a List of size 2. What I want is to use the varargs signature of String, so to combine somehow the item into the array or "explode" the array and then the result will "merge" with the single argument.</p>
  
  <p>What I tried?</p>
  
  <pre><code>List&lt;String&gt; arraylist = new ArrayList&lt;&gt;(list);
  arraylist.add(item);
  List&lt;String&gt; combined = List.copyOf(arraylist);
  </code></pre>
  
  <p>This is very inefficient. Can I do better?</p>