Returns an unmodifiable list containing an arbitrary number of elements. See Unmodifiable Lists for details.
<E> | the List 's element type | |
elements | the elements to be contained in the list |
List
containing the specified elements
NullPointerException | if an element is null or if the array is null |
@apiNote This method also accepts a single array as an argument. The element type of the resulting list will be the component type of the array, and the size of the list will be equal to the length of the array. To create a list with a single element that is an array, do the following:
String[] array = ... ;
List<String[]> list = List.<String[]>of(array);
This will cause the List.of(E)
method
to be invoked instead.
Diagram: Collection List