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

RahimV

RahimV

My name is RahimV and I have over 16 years of experience in designing and developing Java applications. Over the years I have worked with many fortune 500 companies as an eCommerce Architect. My goal is to provide high quality but simple to understand Java tutorials and examples for free. If you like my website, follow me on Facebook and Twitter.

Add Comment

Your email address will not be published. Required fields are marked *