Collections.emptyMap() in Java

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

Syntax:

<Object, Object> Map<Object, Object> java.util.Collections.emptyMap()

This method returns an empty map.

Note: This map is serializable.

Parameters: NA

Returns: an empty map.

Exceptions: NA

Approach

Java

import java.util.Collections;

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

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

    }
}

Output:

{}


No comments:

Post a Comment