Here you can find the source of createHashMap(int size)
Parameter | Description |
---|---|
K | the key type |
V | the value type |
size | the preferred size |
public static <K, V> Map<K, V> createHashMap(int size)
//package com.java2s; //License from project: LGPL import java.util.HashMap; import java.util.Map; public class Main { /**// ww w . j a v a 2 s . co m * Creates the hash map instance that will hold the given amount of elements. The returned * instance is optimized for that size and will not grow until the given number of elements are * added. * <p> * The method is same as <code>new HashMap<K, V>((int) (size * 1.1), 0.95f)</code> * * @param <K> * the key type * @param <V> * the value type * @param size * the preferred size * @return the map instance */ public static <K, V> Map<K, V> createHashMap(int size) { return new HashMap<K, V>((int) (size * 1.1), 0.95f); } }