Skip to content

Java LinkedHashMap Size Example

This example shows how to get LinkedHashMap size in Java (LinkedHashMap length). This example also shows how to get the number of mappings stored in the LinkedHashMap using the size method.

How to get LinkedHashMap size in Java?

The size method of the LinkedHashMap class returns the number of mappings stored in the LinkedHashMap object.

The size method returns an int value equal to the key-value mapping stored in the map object.

Output

You can use the size method of the LinkedHashMap class to check if the LinkedHashMap is empty or not. To do that, you can get the size of the map object and then compare it with zero. If it is equal to zero, then the map is empty, otherwise not.

Output

This example is a part of the Java LinkedHashMap tutorial with examples.

Please let me know your views in the comments section below.

References:
Java 8 LinkedHashMap

About the author

Leave a Reply

Your email address will not be published.