Class ObjectArrays
java.lang.Object
com.google.common.collect.ObjectArrays
Static utility methods pertaining to object arrays.
- Since:
- 2.0
- Author:
- Kevin Bourrillion
-
Method Summary
Modifier and TypeMethodDescriptionconcat
(T[] array, T element) Returns a new array that appendselement
toarray
.Returns a new array that contains the concatenated contents of two arrays.concat
(T element, T[] array) Returns a new array that prependselement
toarray
.Returns a new array of the given length with the specified component type.newArray
(T[] reference, int length) Returns a new array of the given length with the same type as a reference array.
-
Method Details
-
newArray
-
newArray
-
concat
@GwtIncompatible public static <T extends @Nullable Object> T[] concat(T[] first, T[] second, Class<@NonNull T> type) Returns a new array that contains the concatenated contents of two arrays.- Parameters:
first
- the first array of elements to concatenatesecond
- the second array of elements to concatenatetype
- the component type of the returned array
-
concat
Returns a new array that prependselement
toarray
.- Parameters:
element
- the element to prepend to the front ofarray
array
- the array of elements to append- Returns:
- an array whose size is one larger than
array
, withelement
occupying the first position, and the elements ofarray
occupying the remaining elements.
-
concat
Returns a new array that appendselement
toarray
.- Parameters:
array
- the array of elements to prependelement
- the element to append to the end- Returns:
- an array whose size is one larger than
array
, with the same contents asarray
, pluselement
occupying the last position.
-