public class Arrays extends Object
Arrays contains static methods which operate on arrays. This code is taken from the
Apache Harmony JDK, licensed under the Apache Software License 2.0.| Constructor and Description |
|---|
Arrays() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
copyOf(T[] original,
int newLength)
Copies specified number of elements in original array to a new array.
|
static <T> T[] |
copyOfRange(T[] original,
int start,
int end)
Copies elements in original array to a new array, from index start(inclusive) to
end(exclusive).
|
public static <T> T[] copyOf(T[] original,
int newLength)
T - type of element in arrayoriginal - the original arraynewLength - the length of copied arrayNegativeArraySizeException - if the newLength is smaller than zeroNullPointerException - if the original array is nullpublic static <T> T[] copyOfRange(T[] original,
int start,
int end)
T - type of element in arrayoriginal - the original arraystart - the start index, inclusiveend - the end index, exclusive, may bigger than length of the arrayArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than original.lengthIllegalArgumentException - if start is bigger than endNullPointerException - if original is nullCopyright © 2006–2014 Apache Software Foundation. All rights reserved.