Package org.kiwiproject.beta.collect
Class KiwiArrays2
- java.lang.Object
-
- org.kiwiproject.beta.collect.KiwiArrays2
-
public final class KiwiArrays2 extends Object
Utilities related to arrays.These utilities can be considered for inclusion into kiwi's
KiwiArraysclass.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]emptyArray(Class<T> type)Creates an empty array of the specified type.static <T> T[]newArray(Class<T> type, int length)Creates a new array of the specified type and length.
-
-
-
Method Detail
-
emptyArray
public static <T> T[] emptyArray(Class<T> type)
Creates an empty array of the specified type.- Type Parameters:
T- the type parameter representing the component type of the array- Parameters:
type- the class object representing the component type of the array- Returns:
- an empty array of the specified type
- Throws:
IllegalArgumentException- if type is null or isVoid.TYPE- See Also:
Array.newInstance(Class, int)- Implementation Note:
- This method exists because
Array.newInstance(Class, int)returns Object and thus requires a cast. Using this method, code can be a little cleaner without a cast.
-
newArray
public static <T> T[] newArray(Class<T> type, int length)
Creates a new array of the specified type and length. All values in the array are null.- Type Parameters:
T- the type parameter representing the component type of the array- Parameters:
type- the class object representing the component type of the arraylength- the length of the new array- Returns:
- a new array of the specified type and length
- Throws:
IllegalArgumentException- if type is null or isVoid.TYPE, or length is negative- See Also:
Array.newInstance(Class, int)- Implementation Note:
- This method exists because
Array.newInstance(Class, int)returns Object and thus requires a cast. Using this method, code can be a little cleaner without a cast.
-
-