Here you can find the source of newHashMap(int size)
public static <K, V> HashMap<K, V> newHashMap(int size)
//package com.java2s; /*/*from w ww .jav a2s . co m*/ * Hibernate Search, full-text search for your domain model * * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. */ import java.util.HashMap; public class Main { public static <K, V> HashMap<K, V> newHashMap(int size) { return new HashMap<K, V>(getInitialCapacityFromExpectedSize(size)); } /** * As the default loadFactor is of 0.75, we need to calculate the initial capacity from the expected size to avoid * resizing the collection when we populate the collection with all the initial elements. We use a calculation * similar to what is done in {@link HashMap#putAll(Map)}. * * @param expectedSize the expected size of the collection * @return the initial capacity of the collection */ private static int getInitialCapacityFromExpectedSize(int expectedSize) { if (expectedSize < 3) { return expectedSize + 1; } return (int) ((float) expectedSize / 0.75f + 1.0f); } }