Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.HashMap; import java.util.Map; public class Main { /** * 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()); } }