Java Utililty Methods Array Create

List of utility methods to do Array Create

Description

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

Method

T[]arrayOf(T... objects)
array Of
return objects;
Object[][]ArrayToArray(Integer obj, Integer[] objArray)
Array To Array
Object[][] objs = new Object[objArray.length][2];
for (int i = 0; i < objArray.length; i++) {
    objs[i] = new Object[] { obj, objArray[i] };
return objs;
Object[]ArrayToObject(byte[] values)
Array To Object
Object[] objects = new Object[values.length];
for (int i = 0; i < values.length; i++) {
    objects[i] = values[i];
return objects;
Class[]newArray()
new Array
return new Class<?>[0];
E[]newArray(Class elementType, int length)
new Array
return null;
double[]newArray(int length, double start, double increment)
Create and fill an array
double[] data = new double[length];
for (int i = 0; i < length; i++, start += increment)
    data[i] = start;
return data;
ObjectnewArray(Object obj, int size)
new Array
if (obj.getClass().equals(Integer.class)) {
    return new int[size];
if (obj.getClass().getName().contains("I")) {
    return new int[size];
if (obj.getClass().getName().contains("F")) {
    return new float[size];
...
ObjectnewArray(Object src, int len)
Return a new array of the same type as the one passed
if (src.getClass() == byte[].class)
    return new byte[len];
if (src.getClass() == char[].class)
    return new char[len];
throw illegal();
String[]newArray(String... args)
new Array
String[] as = new String[args.length];
for (int i = 0; i < args.length; i++) {
    as[i] = args[i];
return as;
String[]toArray(String source, String delimiter)
to Array
if (isEmpty(source)) {
    return new String[0];
} else {
    return source.split(delimiter);