Java Utililty Methods Array

List of utility methods to do Array

Description

The list of methods to do Array are organized into topic(s).

Method

String[]arrayPush(String[] array, String push)
array Push
String[] longer = new String[array.length + 1];
System.arraycopy(array, 0, longer, 0, array.length);
longer[array.length] = push;
return longer;
booleanarrayRangeEquals(byte[] a, int aOffset, byte[] b, int bOffset, int byteCount)
array Range Equals
for (int i = 0; i < byteCount; i++) {
    if (a[i + aOffset] != b[i + bOffset])
        return false;
return true;
booleanarrayRepresentsProbability(double[] probs)
array Represents Probability
double sum = 0;
for (int i = 0; i < probs.length; i++) {
    sum += probs[i];
    if (probs[i] < 0) {
        return false;
if (Math.abs(sum - 1) < 0.00001) {
...
booleanarraySame(Object[] array1, Object[] array2)
Returns true if the two specified arrays contain the same object in every position.
if (array1 == null || array2 == null || array1.length != array2.length) {
    throw new IllegalArgumentException("array1 and array2 cannot be null and should have same length");
for (int i = 0; i < array1.length; i++) {
    if (array1[i] != array2[i]) {
        return false;
return true;
String[][]arraysConvert(String[] src, int column)
arrays Convert
int row = src.length / column;
String[][] tmp = new String[row][src.length / row];
for (int i = 0; i < row; i++) {
    tmp[i] = new String[column];
    System.arraycopy(src, i * column, tmp[i], 0, column);
return tmp;
T[]arraySeekDelete(final T[] arr, final T[] dest, final T... dels)
array Seek Delete
if (arr == null || dest == null || dest.length != arr.length - dels.length) {
    throw (new IllegalArgumentException("null or invalid array argument"));
for (int i = 0; i < dels.length; i++) {
    for (int ii = 0, offs = 0; ii < arr.length; ii++) {
        if (ii >= dest.length) {
            return null;
        if (arr[ii] != dels[i]) {
            dest[ii - offs] = arr[ii];
        } else {
            offs++;
return dest;
StringarrayStr(int[] A)
Converts an array to a human-readable string, for debugging purposes.
if (A == null)
    return "{null}";
String str = "";
for (int n = 0; n < A.length; n++)
    str += (n > 0 ? "," : "") + A[n];
return str;
StringarrayString(double[] test)
array String
StringBuffer sb = new StringBuffer();
for (double d : test) {
    addToArrayString(sb, d);
sb.append("]");
return sb.toString();
StringarrayString(int[] data)
array String
if (data == null)
    return null;
StringBuffer buf = new StringBuffer();
for (int i = 0; i < data.length; i++) {
    buf.append(data[i] + " ");
return buf.toString();
StringarrayStringR(double[] data)
array String R
if (data == null)
    return null;
StringBuffer buf = new StringBuffer();
for (int i = 0; i < data.length; i++) {
    buf.append(round(data[i]) + " ");
return buf.toString();