Class Arrays
java.util.Arrays.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedArrays()Makes this class non instantiable, but still let's others inherit from it. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]ensureCapacity(boolean[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static byte[]ensureCapacity(byte[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static char[]ensureCapacity(char[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static double[]ensureCapacity(double[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static float[]ensureCapacity(float[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static int[]ensureCapacity(int[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static long[]ensureCapacity(long[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static short[]ensureCapacity(short[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static Object[]ensureCapacity(Object[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements.static StringtoString(boolean[] array) Returns a string representation of the specified array.static StringtoString(byte[] array) Returns a string representation of the specified array.static StringtoString(char[] array) Returns a string representation of the specified array.static StringtoString(double[] array) Returns a string representation of the specified array.static StringtoString(float[] array) Returns a string representation of the specified array.static StringtoString(int[] array) Returns a string representation of the specified array.static StringtoString(long[] array) Returns a string representation of the specified array.static StringtoString(short[] array) Returns a string representation of the specified array.static StringReturns a string representation of the specified array.static boolean[]trimToCapacity(boolean[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static byte[]trimToCapacity(byte[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static char[]trimToCapacity(char[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static double[]trimToCapacity(double[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static float[]trimToCapacity(float[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static int[]trimToCapacity(int[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static long[]trimToCapacity(long[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static short[]trimToCapacity(short[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.static Object[]trimToCapacity(Object[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements.
-
Constructor Details
-
Arrays
protected Arrays()Makes this class non instantiable, but still let's others inherit from it.
-
-
Method Details
-
ensureCapacity
public static byte[] ensureCapacity(byte[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static char[] ensureCapacity(char[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static double[] ensureCapacity(double[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static float[] ensureCapacity(float[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static int[] ensureCapacity(int[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static long[] ensureCapacity(long[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static short[] ensureCapacity(short[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
ensureCapacity
public static boolean[] ensureCapacity(boolean[] array, int minCapacity) Ensures that a given array can hold up tominCapacityelements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
toString
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters", "(comma and space).- Returns:
- a string representation of the specified array.
-
trimToCapacity
public static byte[] trimToCapacity(byte[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static char[] trimToCapacity(char[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static double[] trimToCapacity(double[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static float[] trimToCapacity(float[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static int[] trimToCapacity(int[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static long[] trimToCapacity(long[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static short[] trimToCapacity(short[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-
trimToCapacity
public static boolean[] trimToCapacity(boolean[] array, int maxCapacity) Ensures that the specified array cannot hold more thanmaxCapacityelements. An application can use this operation to minimize array storage.Returns the identical array if
array.length <= maxCapacity. Otherwise, returns a new array with a length ofmaxCapacitycontaining the firstmaxCapacityelements ofarray.- Parameters:
maxCapacity- the desired maximum capacity.
-