次の方法で共有


Collections.NCopies(Int32, Object) Method

Definition

Returns an immutable list consisting of n copies of the specified object.

[Android.Runtime.Register("nCopies", "(ILjava/lang/Object;)Ljava/util/List;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public static System.Collections.IList NCopies (int n, Java.Lang.Object? o);
[<Android.Runtime.Register("nCopies", "(ILjava/lang/Object;)Ljava/util/List;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
static member NCopies : int * Java.Lang.Object -> System.Collections.IList

Parameters

n
Int32

the number of elements in the returned list.

o
Object

the element to appear repeatedly in the returned list.

Returns

an immutable list consisting of n copies of the specified object.

Attributes

Remarks

Returns an immutable list consisting of n copies of the specified object. The newly allocated data object is tiny (it contains a single reference to the data object). This method is useful in combination with the List.addAll method to grow lists. The returned list is serializable.

Java documentation for java.util.Collections.nCopies(int, 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