Condividi tramite


Arrays.CopyOf Method

Definition

Overloads

CopyOf(Int32[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

CopyOf(Object[], Int32, Class)

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

CopyOf(Single[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

CopyOf(Int64[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

CopyOf(Int16[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

CopyOf(Boolean[], Int32)

Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.

CopyOf(Char[], Int32)

Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length.

CopyOf(Byte[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

CopyOf(Double[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

CopyOf(Object[], Int32)

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

CopyOf(Int32[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([II)[I", "")]
public static int[] CopyOf (int[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([II)[I", "")>]
static member CopyOf : int[] * int -> int[]

Parameters

original
Int32[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Int32[]

a copy of the original array, truncated or padded with zeros to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(int[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Object[], Int32, Class)

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([Ljava/lang/Object;ILjava/lang/Class;)[Ljava/lang/Object;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T", "U" })]
public static Java.Lang.Object[] CopyOf (Java.Lang.Object[] original, int newLength, Java.Lang.Class newType);
[<Android.Runtime.Register("copyOf", "([Ljava/lang/Object;ILjava/lang/Class;)[Ljava/lang/Object;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T", "U" })>]
static member CopyOf : Java.Lang.Object[] * int * Java.Lang.Class -> Java.Lang.Object[]

Parameters

original
Object[]

the array to be copied

newLength
Int32

the length of the copy to be returned

newType
Class

the class of the copy to be returned

Returns

Object[]

a copy of the original array, truncated or padded with nulls to obtain the specified length

Attributes

Remarks

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of the class newType.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(U[], int, java.lang.Class<? extends T[]>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Single[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([FI)[F", "")]
public static float[] CopyOf (float[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([FI)[F", "")>]
static member CopyOf : single[] * int -> single[]

Parameters

original
Single[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Single[]

a copy of the original array, truncated or padded with zeros to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0f. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(float[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Int64[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([JI)[J", "")]
public static long[] CopyOf (long[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([JI)[J", "")>]
static member CopyOf : int64[] * int -> int64[]

Parameters

original
Int64[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Int64[]

a copy of the original array, truncated or padded with zeros to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0L. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(long[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Int16[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([SI)[S", "")]
public static short[] CopyOf (short[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([SI)[S", "")>]
static member CopyOf : int16[] * int -> int16[]

Parameters

original
Int16[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Int16[]

a copy of the original array, truncated or padded with zeros to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain (short)0. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(short[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Boolean[], Int32)

Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([ZI)[Z", "")]
public static bool[] CopyOf (bool[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([ZI)[Z", "")>]
static member CopyOf : bool[] * int -> bool[]

Parameters

original
Boolean[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

a copy of the original array, truncated or padded with false elements to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain false. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(boolean[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Char[], Int32)

Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([CI)[C", "")]
public static char[] CopyOf (char[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([CI)[C", "")>]
static member CopyOf : char[] * int -> char[]

Parameters

original
Char[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Char[]

a copy of the original array, truncated or padded with null characters to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain '\u005cu0000'. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(char[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Byte[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([BI)[B", "")]
public static byte[] CopyOf (byte[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([BI)[B", "")>]
static member CopyOf : byte[] * int -> byte[]

Parameters

original
Byte[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Byte[]

a copy of the original array, truncated or padded with zeros to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain (byte)0. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(byte[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Double[], Int32)

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([DI)[D", "")]
public static double[] CopyOf (double[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([DI)[D", "")>]
static member CopyOf : double[] * int -> double[]

Parameters

original
Double[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Double[]

a copy of the original array, truncated or padded with zeros to obtain the specified length

Attributes

Exceptions

if original == null

Remarks

Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0d. Such indices will exist if and only if the specified length is greater than that of the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(double[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CopyOf(Object[], Int32)

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

[Android.Runtime.Register("copyOf", "([Ljava/lang/Object;I)[Ljava/lang/Object;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static Java.Lang.Object[] CopyOf (Java.Lang.Object[] original, int newLength);
[<Android.Runtime.Register("copyOf", "([Ljava/lang/Object;I)[Ljava/lang/Object;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member CopyOf : Java.Lang.Object[] * int -> Java.Lang.Object[]

Parameters

original
Object[]

the array to be copied

newLength
Int32

the length of the copy to be returned

Returns

Object[]

a copy of the original array, truncated or padded with nulls to obtain the specified length

Attributes

Remarks

Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of exactly the same class as the original array.

Added in 1.6.

Java documentation for java.util.Arrays.copyOf(T[], int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to