Class ArrayUtils
java.lang.Object
gaiasky.util.ArrayUtils
Utilities to work with arrays.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]Returns a new array containing all elements of the original array plus the specified value appended at the end.static <T> T[]concatWithArrayCopy(T[] array1, T[] array2) Concatenates the given arrays into a new array.static float[]toFloatArray(double[] arr) Convert a double array to a float array.
-
Constructor Details
-
ArrayUtils
public ArrayUtils()
-
-
Method Details
-
concatWithArrayCopy
public static <T> T[] concatWithArrayCopy(T[] array1, T[] array2) Concatenates the given arrays into a new array.- Type Parameters:
T- Array element types.- Parameters:
array1- The first array.array2- The second array.- Returns:
- A new array which contains array1 + array2.
-
toFloatArray
public static float[] toFloatArray(double[] arr) Convert a double array to a float array.- Parameters:
arr- The double array.- Returns:
- The float array.
-
addString
Returns a new array containing all elements of the original array plus the specified value appended at the end.Since Java arrays are immutable in size, this method creates a new array, copies the original contents, and adds the new value.
- Parameters:
original- the source array; may benullvalue- the string to append to the array- Returns:
- a new array containing the original elements and the appended value
-