title: Merging 2 arrays into 1 in Java
body: <p>Okay so i have this following exercise i need to merge 2 arrays together into 1 array.</p>
  
  <hr>
  
  <p>The new array has to containt elements of each array e.g: newArray index 0 = array1Element from 0 index,  newArray index 1 = array2Element from index 0 and so on..</p>
  
  <p>If one of those arrays has no more elements, continue putting elements from the longer array... so far i have come to this..which is of not right or isn't giving the right solution..can you please give me a proper solution and explain everything that was done in the code..</p>
  
  <pre><code>public static void main(String[] args) {
      int[] array1 = {1,1,1,1,1,1};
      int[] array2 = {2,2,2,2,2,2,2,2,2,2};
      arrayMan(array1,array2);
  }
  
  public static int[] arrayMan(int[] firstArray,int[] secondArray) {
      int[] newArray = new int[firstArray.length + secondArray.length];
      int array1Pos;
      int array2Pos;
      System.arraycopy(firstArray,0,newArray,0,firstArray.length);
      for (int i = 0; i &lt; newArray.length -1 ; i++) {
          for (int j = 0; j &lt; secondArray.length ; j++) {
              if(newArray[i] == newArray[i+1]) {
                  array1Pos = newArray[i+1];
                  array2Pos = secondArray[j];
                      newArray[i] = array1Pos;
                      newArray[i + 1] = array2Pos;
              }
          }
      }
      for (int i = 0; i &lt; newArray.length ; i++) {
          System.out.println(newArray[i]);
      }
  
  
      return newArray;
  }
  </code></pre>
  
  <p>The expected output should be {1,2,1,2,1,2,1,2,1,2,1,2,2,2,2}</p>