Java LinkedHashMap(int initialCapacity) Constructor
Syntax
LinkedHashMap(int initialCapacity) constructor from LinkedHashMap has the following syntax.
public LinkedHashMap(int initialCapacity)
Example
In the following code shows how to use LinkedHashMap.LinkedHashMap(int initialCapacity) constructor.
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/* w w w.ja v a 2s.c o m*/
public class Main {
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<String, Integer>();
// add some values in the map
map.put("One", 1);
map.put("Two", 2);
map.put("Three", 3);
LinkedHashMap<String, Integer> linkMap = new LinkedHashMap<String, Integer>(
map);
System.out.println(linkMap);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »