title: How do i merge multiple lists of string arrays in Java?
body: <p>I'm working in Java and I have three lists consisting of arrays filled with strings (List) of which I've made streams. The first list contains multiple arrays with two strings inside (let's call them COUNTRY, and CITY). The second list has the same format but consists of CITY and ROAD, and then the final list contains arrays with 5 strings (ROAD, A, B, C, and D). </p>
  
  <p>What I need to do is merge these three lists into one where each COUNTRY is linked to every ROAD based on the CITY value if they match, and then add all the data we have from each ROAD.</p>
  
  <p>So for example going from:</p>
  
  <pre><code>List1: ["COUNTRY1", "CITY1"], [...]
  List2: ["CITY1", "ROAD1"], [...]
  List3: ["ROAD1", "A", "B", "C", "D"], [...]
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>output: ["COUNTRY1", "CITY1", "ROAD1", "A", "B", "C", "D"]
  </code></pre>
  
  <p>it is important to note that each country appears multiple times with different cities, and each city appears multiple times with different roads, sometimes multiple cities share the same road, but in the list of arrays with 5 strings, each road is unique.</p>
  
  <p>tl;dr : </p>
  
  <p>I need to merge all roads and their data to cities they're associated with, and to countries associated with those cities. I'm completely new to Java but I was told Streams are the way to go since my data contains a couple of dozen GBs.</p>
  
  <p>Is there an efficient way to do this?</p>