Share via


Collections.CheckedList(IList, Class) Method

Definition

Returns a dynamically typesafe view of the specified list.

[Android.Runtime.Register("checkedList", "(Ljava/util/List;Ljava/lang/Class;)Ljava/util/List;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "E" })]
public static System.Collections.IList CheckedList (System.Collections.IList list, Java.Lang.Class type);
[<Android.Runtime.Register("checkedList", "(Ljava/util/List;Ljava/lang/Class;)Ljava/util/List;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "E" })>]
static member CheckedList : System.Collections.IList * Java.Lang.Class -> System.Collections.IList

Parameters

list
IList

the list for which a dynamically typesafe view is to be returned

type
Class

the type of element that list is permitted to hold

Returns

a dynamically typesafe view of the specified list

Attributes

Remarks

Returns a dynamically typesafe view of the specified list. Any attempt to insert an element of the wrong type will result in an immediate ClassCastException. Assuming a list contains no incorrectly typed elements prior to the time a dynamically typesafe view is generated, and that all subsequent access to the list takes place through the view, it is guaranteed that the list cannot contain an incorrectly typed element.

A discussion of the use of dynamically typesafe views may be found in the documentation for the #checkedCollection checkedCollection method.

The returned list will be serializable if the specified list is serializable.

Since null is considered to be a value of any reference type, the returned list permits insertion of null elements whenever the backing list does.

Added in 1.5.

Java documentation for java.util.Collections.checkedList(java.util.List<E>, java.lang.Class<E>).

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