Create new HashMap by size - Java java.util

Java examples for java.util:HashMap

Description

Create new HashMap by size

Demo Code


//package com.book2s;

import java.util.HashMap;

public class Main {
    public static void main(String[] argv) {
        System.out.println(newHashMap());
    }/*  ww w.  ja va2  s  . c o  m*/

    public static <T, K> HashMap<T, K> newHashMap() {
        return new HashMap<T, K>();
    }

    public static <T, K> HashMap<T, K> newHashMap(int size) {
        return new HashMap<T, K>((int) (size / 0.75));
    }
}

Related Tutorials