Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Value of returned list: [A, B, C, D, E]

Example 2

Test it Now

Output:

Value of returned list: [1, 2, 3, 4, 5]

Example 3

Test it Now

Output:

List elements: [Java, PHP, Array, String, C++]






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA