What would be the best way to merge two arrays of different lengths together so they are evenly distributed in the new array?
Say I have the following arrays
String[] array1 = new String[7];
String[] array2 = new String[2];
String[] mergedArray = new String[array1.length + array2.length];
I would want mergedArray to have the following elements
array1 array1 array1 array2 array1 array1 array1 array2 array1
but if I were to change the size of the arrays to
String[] array1 = new String[5];
String[] array2 = new String[3];
String[] mergedArray = new String[array1.length + array2.length];
then I would want it to be
array1 array2 array1 array2 array1 array2 array1 array1
basically if it can be helped each array2
element shouldn't be touching each other; exception if array2
has a size larger than array1
.