List of utility methods to do Array From
String[] | toArray(E[] o) to Array String[] output = new String[o.length]; for (int i = 0; i < output.length; i++) output[i] = o[i].name(); return output; |
double[] | toArray(final double d) Take a single value and create an array that holds it. final double[] result = new double[1]; result[0] = d; return result; |
int[] | toArray(final int ip) Convert a packed integer IP address into a 4-element array. final int[] ret = new int[IP_PARTS]; for (int j = 3; j >= 0; --j) { ret[j] |= ip >>> 8 * (3 - j) & 0xff; return ret; |
Object[] | ToArray(final Object... toSmashIntoArray) To Array return toSmashIntoArray;
|
char[][] | toArray(final String[] strings) to Array if (strings == null) { return null; final char[][] res = new char[strings.length][]; for (int i = 0; i < strings.length; i++) { res[i] = strings[i].toCharArray(); return res; ... |
T[] | toArray(final T... array) Create a type-safe generic array. return array;
|
T[] | toArray(final T... items) Create a type-safe generic array. The Java language does not allow an array to be created from a generic type: public static <T> T[] createAnArray(int size) { return new T[size]; // compiler error here } public static <T> T[] createAnArray(int size) { return (T[])new Object[size]; // ClassCastException at runtime } Therefore new arrays of generic types can be created with this method. return items;
|
String[] | toArray(final Throwable throwable) Returns an string array representation of the specified throwable. final StackTraceElement[] st = throwable.getStackTrace(); final int sl = st.length; final String[] obj = new String[sl + 1]; obj[0] = throwable.toString(); for (int s = 0; s < sl; s++) obj[s + 1] = "\tat " + st[s]; return obj; |
Object[] | toArray(float[] floatArray) to Array if (floatArray == null) return null; Float[] objArray = new Float[floatArray.length]; for (int i = 0; i < floatArray.length; i++) objArray[i] = Float.valueOf(floatArray[i]); return objArray; |
Object[] | toArray(int arg1) to Array return new Object[] { new Integer(arg1) }; |