Returns consecutive sub arrays of an array, each of the same size (the final list may be smaller),
or an empty List if the specified array is null or empty.

@param a
@param size
@return
177266
public static List<boolean[]> split(final boolean[] a, final int size) {
        if (size < 1) {
            throw new IllegalArgumentException("The parameter 'size' can not be zero or less than zero");
        }

        if (N.isNullOrEmpty(a)) {
            return new ArrayList<>();
        }

        final int len = a.length;
        final List<boolean[]> res = new ArrayList<>(len % size == 0 ? len / size : (len / size) + 1);

        for (int from = 0, toIndex = a.length; from < toIndex; from += size) {
            res.add(copyOfRange(a, from, from <= toIndex - size ? from + size : toIndex));
        }

        return res;
    }
441841
public static <T> T[] createArray(int size, T defaultValue) {
		T[] result = (T[]) GenericReflection.newArray(defaultValue.getClass(), size);
		for (int i = 0; i < result.length; i++) {
			result[i] = defaultValue;
		}
		return result;
	}
313569
public static boolean arrayEquals(List<String> a, List<String> b) {
        if (a == null) {
            a = new ArrayList<>();
        }
        if (b == null) {
            b = new ArrayList<>();
        }
        if (a.size() != b.size()) {
            return false;
        }

        for (int i = 0; i < a.size(); i ++) {
            if (!a.get(i).equals(b.get(i))) {
                return false;
            }
        }
        return true;
    }
689321
public static <T> List<T> sub(List<T> list, int start, int end, int step) {
		if (list == null || list.isEmpty()) {
			return null;
		}

		final int size = list.size();
		if (start < 0) {
			start += size;
		}
		if (end < 0) {
			end += size;
		}
		if (start == size) {
			return new ArrayList<>(0);
		}
		if (start > end) {
			int tmp = start;
			start = end;
			end = tmp;
		}
		if (end > size) {
			if (start >= size) {
				return new ArrayList<>(0);
			}
			end = size;
		}

		if (step <= 1) {
			return list.subList(start, end);
		}

		final List<T> result = new ArrayList<>();
		for (int i = start; i < end; i += step) {
			result.add(list.get(i));
		}
		return result;
	}
335344
public static int[] randomPermutation(int size) {
        Random r = new Random();
        int[] result = new int[size];

        for (int j = 0; j < size; j++) {
            result[j] = j;
        }
        
        for (int j = size - 1; j > 0; j--) {
            int k = r.nextInt(j);
            int temp = result[j];
            result[j] = result[k];
            result[k] = temp;
        }

        return result;
    }
278850
@SafeVarargs
    @NullSafe
    public static <T> List<T> asList(T... a) {
        return N.isNullOrEmpty(a) ? N.<T> emptyList() : Arrays.asList(a);
    }
3943
function(size){
  this.data = [];
  if(typeof size === 'undefined'){
    return; // Empty instance of a bit array
  }
  if(typeof size !== 'number'){
    size = shred(size);
  }
  for(var i=0; i<Math.ceil(size/INTEGER_SIZE); ++i){
    this.data.push(0);
  }
}
1290598
public JBBPDslBuilder CustomArray(final String type, final String size) {
    return this.CustomArray(type, null, size, null);
  }
809912
public static List<Integer> asList(int[] a) {
    List<Integer> result = new ArrayList<Integer>(a.length);
    for (int i = 0; i < a.length; i++) {
      result.add(Integer.valueOf(a[i]));
    }
    return result;
  }
1249732
public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array) {
        ArrayList<A> elements = new ArrayList<>();
        while (enumeration.hasMoreElements()) {
            elements.add(enumeration.nextElement());
        }
        return elements.toArray(array);
    }
374260
public static String[] subarrayOf
            (final String[] array,
             final int start,
             final int end)
        {
        final int subarraySize = end - start;
        final String[] subarray = new String[subarraySize];

        for (int i = 0; i < subarraySize; ++i)
            {
            subarray[i] = array[i + start];
            }

        return (subarray);
        }
1214417
private static List<String> initialiseResult(int size) {
		final List<String> result = new ArrayList<>(size);
		for (int i = 0; i < size; i++) {
			result.add("");
		}
		return result;
	}
1206325
public static <T> List<T> toList(final T[] array) {

    if (array != null) {
      List<T> list = new ArrayList<T>(array.length);
      for (T element : array) {
        list.add(element);
      }
      return list;
    } else {
      return new ArrayList<T>(0);
    }
  }
819565
@Nullable
  public static int[] getIntArray(@Nullable final JsonArray array) {
    if (null == array) return null;
    return IntStream.range(0, array.size()).map(i -> array.get(i).getAsInt()).toArray();
  }
781735
public static Integer[] createAndInitializeArray(int size, Integer start) {
		Integer[] result = new Integer[size];
		for (int i = 0; i < result.length; i++) {
			result[i] = start++;
		}
		return result;
	}
1334802
private static String[] copyOf(String[] orig, int size) {
        final String[] copy = new String[size];
        System.arraycopy(orig, 0, copy, 0,
                Math.min(orig.length, size));
        return copy;
    }
852693
public static Matrix constructWithCopy(double[][] A)
    {
        int m = A.length;
        int n = A[0].length;
        Matrix X = new Matrix(m, n);
        double[][] C = X.getArray();
        for (int i = 0; i < m; i++)
        {
            if (A[i].length != n)
            {
                throw new IllegalArgumentException
                        ("All rows must have the same length.");
            }
            for (int j = 0; j < n; j++)
            {
                C[i][j] = A[i][j];
            }
        }
        return X;
    }