Create a new empty array with the same type as the passed array.

@param <ELEMENTTYPE>
Type of element
@param aArray
Source array. May not be <code>null</code>.
@param nSize
Destination size. Must be &ge; 0.
@return Never <code>null</code>.
976883
@Nonnull
  @ReturnsMutableCopy
  public static <ELEMENTTYPE> ELEMENTTYPE [] newArraySameType (@Nonnull final ELEMENTTYPE [] aArray,
                                                               @Nonnegative final int nSize)
  {
    return newArray (getComponentType (aArray), nSize);
  }
203522
private ReferenceType computeFirstCommonSuperclassOfSameDimensionArrays(ArrayType aArrType, ArrayType bArrType)
            throws ClassNotFoundException {
        assert aArrType.getDimensions() == bArrType.getDimensions();

        Type aBaseType = aArrType.getBasicType();
        Type bBaseType = bArrType.getBasicType();
        boolean aBaseIsObjectType = (aBaseType instanceof ObjectType);
        boolean bBaseIsObjectType = (bBaseType instanceof ObjectType);

        if (!aBaseIsObjectType || !bBaseIsObjectType) {
            assert (aBaseType instanceof BasicType) || (bBaseType instanceof BasicType);

            if (aArrType.getDimensions() > 1) {
                // E.g.: first common supertype of int[][] and WHATEVER[][] is
                // Object[]
                return new ArrayType(Type.OBJECT, aArrType.getDimensions() - 1);
            } else {
                assert aArrType.getDimensions() == 1;
                // E.g.: first common supertype type of int[] and WHATEVER[] is
                // Object
                return Type.OBJECT;
            }
        } else {
            assert (aBaseType instanceof ObjectType);
            assert (bBaseType instanceof ObjectType);

            // Base types are both ObjectTypes, and number of dimensions is
            // same.
            // We just need to find the first common supertype of base types
            // and return a new ArrayType using that base type.
            ObjectType firstCommonBaseType = getFirstCommonSuperclass((ObjectType) aBaseType, (ObjectType) bBaseType);
            return new ArrayType(firstCommonBaseType, aArrType.getDimensions());
        }
    }
1047317
public void push(KType[] elements, int start, int len) {
    assert start >= 0 && len >= 0;

    ensureBufferSpace(len);
    System.arraycopy(elements, start, buffer, elementsCount, len);
    elementsCount += len;
  }
175776
public static Type array(Type elementType) {
    Preconditions.checkNotNull(elementType);
    switch (elementType.getCode()) {
      case BOOL:
        return TYPE_ARRAY_BOOL;
      case INT64:
        return TYPE_ARRAY_INT64;
      case FLOAT64:
        return TYPE_ARRAY_FLOAT64;
      case STRING:
        return TYPE_ARRAY_STRING;
      case BYTES:
        return TYPE_ARRAY_BYTES;
      case TIMESTAMP:
        return TYPE_ARRAY_TIMESTAMP;
      case DATE:
        return TYPE_ARRAY_DATE;
      default:
        return new Type(Code.ARRAY, elementType, null);
    }
  }
1290372
public static <T> List<T> toList(JSONArray jsonArray, Class<T> elementType) {
		return null == jsonArray ? null : jsonArray.toList(elementType);
	}
1233627
public static boolean isArrayEquals (@Nullable final Object aHeadArray, @Nullable final Object aTailArray)
  {
    // Same objects?
    if (EqualsHelper.identityEqual (aHeadArray, aTailArray))
      return true;

    // Any of the null -> different because they are not both null
    if (aHeadArray == null || aTailArray == null)
      return false;

    // If any of the passed object is not an array -> not equal as an array,
    // even if they are equal!
    if (!isArray (aHeadArray) || !isArray (aTailArray))
      return false;

    // Different component type?
    if (!aHeadArray.getClass ().getComponentType ().equals (aTailArray.getClass ().getComponentType ()))
      return false;

    // Different length?
    final int nLength = Array.getLength (aHeadArray);
    if (nLength != Array.getLength (aTailArray))
      return false;

    // Compare step by step
    for (int i = 0; i < nLength; i++)
    {
      final Object aItem1 = Array.get (aHeadArray, i);
      final Object aItem2 = Array.get (aTailArray, i);
      if (isArray (aItem1) && isArray (aItem2))
      {
        // Recursive call
        if (!isArrayEquals (aItem1, aItem2))
          return false;
      }
      else
      {
        // Use equals implementation
        if (!EqualsHelper.equals (aItem1, aItem2))
          return false;
      }
    }

    // No differences found!
    return true;
  }
5412
@SuppressWarnings(
   {
      "unchecked"
   }) public static final <E extends Enum<E>> E[] createTypeArray(Class<E> c, int arraySizeOffset)
   {
      EnumSet<E> set = EnumSet.allOf(c);
      E[] array = (E[]) Array.newInstance(c, set.size() + arraySizeOffset);

      for (E e : set)
      {
         int index = ((MpxjEnum) e).getValue();
         if (index >= 0)
         {
            array[index] = e;
         }
      }
      return array;
   }
1156675
static ArrayBlock createArrayBlockInternal(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)
    {
        validateConstructorArguments(arrayOffset, positionCount, valueIsNull, offsets, values);
        return new ArrayBlock(arrayOffset, positionCount, valueIsNull, offsets, values);
    }
63709
public static Type newArrayType(Type componentType) {
    if (componentType instanceof Class<?>) {
      return newArrayType((Class<?>) componentType);
    }
    final TypeVariable<?> var = TypeVariableGenerator.freshTypeVariable("E");
    return new TypeResolver().where(var, componentType).resolveType(new GenericArrayType() {
      @Override public Type getGenericComponentType() { return var; }
    });
  }
235493
public static boolean[] add(final boolean[] a, final boolean element) {
        if (N.isNullOrEmpty(a)) {
            return Array.of(element);
        }

        final boolean[] newArray = new boolean[a.length + 1];

        copy(a, 0, newArray, 0, a.length);
        newArray[a.length] = element;

        return newArray;
    }
502274
private void redimNodeArrays(int newsize) {
        int len = newsize < lo.length ? newsize : lo.length;
        char[] na = new char[newsize];
        System.arraycopy(lo, 0, na, 0, len);
        lo = na;
        na = new char[newsize];
        System.arraycopy(hi, 0, na, 0, len);
        hi = na;
        na = new char[newsize];
        System.arraycopy(eq, 0, na, 0, len);
        eq = na;
        na = new char[newsize];
        System.arraycopy(sc, 0, na, 0, len);
        sc = na;
    }
1316098
public Type setArrayElementType(Type elementType)
        throws IntrospectionException {
        Type type = new Type(mGenericType, mNaturalClass);
        type.checkForArrayLookup();
        type.mArrayElementType = elementType;
        return type;
    }
1279743
protected void allocateBuffers(int arraySize) {
    assert Integer.bitCount(arraySize) == 1;

    // Compute new hash mixer candidate before expanding.
    final int newKeyMixer = this.orderMixer.newKeyMixer(arraySize);

    // Ensure no change is done if we hit an OOM.
    KType[] prevKeys = Intrinsics.<KType[]> cast(this.keys);
    try {
      int emptyElementSlot = 1;
      this.keys = Intrinsics.<KType> newArray(arraySize + emptyElementSlot);
    } catch (OutOfMemoryError e) {
      this.keys = prevKeys;
      throw new BufferAllocationException(
          "Not enough memory to allocate buffers for rehashing: %,d -> %,d", 
          e,
          this.keys == null ? 0 : size(), 
          arraySize);
    }

    this.resizeAt = expandAtCount(arraySize, loadFactor);
    this.keyMixer = newKeyMixer;
    this.mask = arraySize - 1;
  }
686092
public static <T extends Number> int[] asArray(final T... array) {
        int[] b = new int[array.length];
        for (int i = 0; i < b.length; i++) {
            b[i] = array[i].intValue();
        }
        return b;
    }
6125
public static @Nonnull Optional<Class> arrayTypeForPrimitive(String primitiveType) {
        if (primitiveType != null) {
            return Optional.ofNullable(PRIMITIVE_ARRAY_MAP.get(primitiveType));
        }
        return Optional.empty();
    }
33156
public static Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive) {
        int newSize = endIndexExclusive - startIndexInclusive;
        Class<?> type = array.getClass().getComponentType();
        if (newSize <= 0) {
            return (Object[]) Array.newInstance(type, 0);
        }
        Object[] subarray = (Object[]) Array.newInstance(type, newSize);
        System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
        return subarray;
    }
155358
@SafeVarargs
  public static <E> RubyArray<E> newRubyArray(E... elements) {
    return new RubyArray<>(new ArrayList<>(Arrays.asList(elements)));
  }