title: List view of concatenated lists
body: <p>I want to create a list view that consists of the concatenation of a number of other lists.</p>
  <p>Example:</p>
  <pre><code>List&lt;Integer&gt; l1 = Lists.newArrayList(1);
  List&lt;Integer&gt; l2 = Lists.newArrayList(2);
  List&lt;Integer&gt; l3 = Lists.newArrayList(3);
  
  // This call should not copy any of the argument lists content
  List&lt;Integer&gt; concatenation = new ConcatenationListView(l1, l2, l3);
  
  System.out.println(concatenation); // Prints [1, 2, 3]
  l3.add(4);
  System.out.println(concatenation); // Prints [1, 2, 3, 4]
  </code></pre>
  <p>What kind of technique and or pattern can I use in Java to fulfill these requirements?</p>
  <h3>Details</h3>
  <ul>
  <li>I want the concatenation to be lazy. (That's the meaning of &quot;view&quot; in this context.)</li>
  <li>I want change to the component lists the reflect on the concatenation. (Also the meaning of &quot;view&quot;).</li>
  <li>The view need not to be modifiable.</li>
  <li>This is kind of the opposite of the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html#subList-int-int-" rel="nofollow noreferrer"><code>List.subList</code></a> method.</li>
  <li>It is similar to what the Guava <a href="https://google.github.io/guava/releases/22.0/api/docs/com/google/common/collect/Iterables.html#concat-java.lang.Iterable-" rel="nofollow noreferrer"><code>Iterables.concat</code></a> method do, but I need a list as the result, not an iterable.</li>
  <li>My question is similar to <a href="https://stackoverflow.com/questions/4896662/combine-multiple-collections-into-a-single-logical-collection/4896878#4896878">this one</a>, but I need a <code>List</code> as the resulting concatenation, where the poster of the other question is content with an <code>Iterable</code> as the result.</li>
  </ul>
  <h3>Edit: Solution</h3>
  <p>I posted a <a href="https://stackoverflow.com/a/48647684/452775">complete solution</a> based on Sergey's answer.</p>