size(): This method is available in java.util.LinkedHashMap class of Java.
Syntax:
int java.util.HashMap.size()
This method returns the number of key-value mappings in this map.
Parameters: NA
Returns: the number of key-value mappings in this map.
Exceptions: NA
Approach
Java
import java.util.LinkedHashMap;public class LinkedHashMapsize {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.size());}}
Output:
2
No comments:
Post a Comment