99
Java Collections list() Method
The list() method of Java Collections class is used to get an array list containing the elements returned by the specified enumeration in the order in which they are returned by the enumeration.
Syntax
Following is the declaration of list() method:
Parameter
Parameter | Description | Required/Optional |
---|---|---|
e | It is the enumeration providing elements for the returned array list. | Required |
Returns
The list() method returns an array list containing the elements returned by the specified enumeration.
Exceptions
NA
Compatibility Version
Java 1.4 and above
Example 1
Output:
Value of returned list: [A, B, C, D, E]
Example 2
Output:
Value of returned list: [1, 2, 3, 4, 5]
Example 3
Output:
List elements: [Java, PHP, Array, String, C++]
Next TopicJava Collections Class