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