Collections.emptyList() in Java

Collections.emptyList(): This method is available in java.util.Collections class of Java.

Syntax:

<Object> List<Object> java.util.Collections.emptyList()

This method returns an empty list.

Note: This list is serializable.

Parameters: NA

Returns: an empty immutable list.

Exceptions: NA

Approach

Java

import java.util.Collections;

public class CollectionsemptyList {
    public static void main(String[] args) {

        System.out.println(Collections.emptyList());

    }
}

Output:

[]


No comments:

Post a Comment