LinkedHashMap(int initialCapacity) constructor from LinkedHashMap has the following syntax.
public LinkedHashMap(int initialCapacity)
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 ww.j a va 2 s . 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.