LinkedHashMap isEmpty() in Java

isEmpty(): This method is available in java.util.LinkedHashMap class of Java.

Syntax:

boolean java.util.HashMap.isEmpty()

This method returns true if this map contains no key-value mappings.

Parameters: NA

Returns: true if this map contains no key-value mappings.

Exceptions: NA

Approach

Java

import java.util.LinkedHashMap;

public class LinkedHashMapisEmpty {

    public static void main(String args[]) {

        LinkedHashMap<String, Integer> linkedHashMap =
new LinkedHashMap<String, Integer>();

        linkedHashMap.put("Java", 1);
        linkedHashMap.put("Hello", 2);

        System.out.println(linkedHashMap.isEmpty());

    }

}

Output:

false


No comments:

Post a Comment