@SuppressWarnings("unchecked")
  public static <T> T[] concat(Class<T> type, T[]... arrays) {
    T[] result = (T[]) Array.newInstance(type, totalLength(arrays));

    int currentLength = 0;

    for (T[] array : arrays) {
      int length = array.length;
      if (length > 0) {
        System.arraycopy(array, 0, result, currentLength, length);
        currentLength += length;
      }
    }

    return result;
  }
@Test
  public void testConcatWithEmptyArrays() {
    String[] array1 = {};
    String[] array2 = {"a", "b"};

    String[] result = ArrayUtil.concat(String.class, array1, array2);
    assertThat(result).isEqualTo(new String[] {"a", "b"});
  }