title: How to concatenate string arrays in Java
body: <p>I'm wondering how I can concatenate 4 string arrays in Java.</p>
  
  <p>There is a question about this already.
  <a href="https://stackoverflow.com/questions/80476/how-to-concatenate-two-arrays-in-java">How can I concatenate two arrays in Java?</a></p>
  
  <p>But I tried to replicate it but it does not work for me.</p>
  
  <p>This is what my code looks like: </p>
  
  <p>Calling the method:</p>
  
  <pre><code>concatAll(jobs1, jobs2, jobs3, jobs4);
  </code></pre>
  
  <p>The method itself:</p>
  
  <pre><code>public String[] concatAll(String[] jobsA, String[] jobsB, String[] jobsC, String[] jobsD) {
      int totalLength = jobsA.length;
      for (String[] array : jobsD) {
          totalLength += array.length;
      }
  
      String[] result = Arrays.copyOf(jobsA, totalLength);
  
      int offset = jobsA.length;
  
      for (String[] array : jobsD) {
          System.arraycopy(array, 0, result, offset, array.length);
          offset += array.length;
      }
      return result;
  }
  </code></pre>