Here you can find the source of newHashMap(int size)
Parameter | Description |
---|---|
size | size of HashMap |
K | keyType |
V | valueType |
public static <K, V> HashMap<K, V> newHashMap(int size)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.HashMap; import java.util.Map; public class Main { /**/* w ww . j a va2s. c o m*/ * Create new {@link HashMap}. * * @param <K> key * @param <V> value * @return {@link HashMap} */ public static <K, V> Map<K, V> newHashMap() { return new HashMap<K, V>(); } /** * Create new {@link HashMap}. * * @param size size of {@link HashMap} * @param <K> keyType * @param <V> valueType * @return created {@link HashMap} instance */ public static <K, V> HashMap<K, V> newHashMap(int size) { return new HashMap<K, V>(size); } /** * Create new {@link HashMap} having same size of given base collection. * * @param base collection which size will be referred * @param <K> keyType * @param <V> valueType * @return created {@link HashMap} instance */ public static <K, V> HashMap<K, V> newHashMap(Collection<?> base) { return new HashMap<K, V>(base.size()); } }