Java tutorial
//package com.java2s; import java.util.HashSet; import java.util.Set; public class Main { public static <V> Set<V> newHashSet(int expectedSize) { return new HashSet<V>(expectedSizeToCapacity(expectedSize)); } private static int expectedSizeToCapacity(int expectedSize) { return 4 * expectedSize / 3 + 1; } }