Collections.emptySet() in Java

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

Syntax:

<Object> Set<Object> java.util.Collections.emptySet()

This method returns an empty set.

Note: This set is serializable.

Parameters: NA

Returns: the empty set.

Exceptions: NA

Approach

Java

import java.util.Collections;

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

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

    }
}

Output:

[]


No comments:

Post a Comment