Create new Weak Hash Map - Java java.util

Java examples for java.util:Collection Creation

Description

Create new Weak Hash Map

Demo Code


//package com.java2s;

import java.util.Map;

import java.util.WeakHashMap;

public class Main {
    public static void main(String[] argv) {
        System.out.println(newWeakHashMap());
    }/*  ww  w .j  a va  2  s  .  com*/

    public static <K, V> WeakHashMap<K, V> newWeakHashMap() {
        return new WeakHashMap<K, V>();
    }

    public static <K, V> WeakHashMap<K, V> newWeakHashMap(
            final int initialCapacity) {
        return new WeakHashMap<K, V>(initialCapacity);
    }

    public static <K, V> WeakHashMap<K, V> newWeakHashMap(
            final int initialCapacity, final float loadFactor) {
        return new WeakHashMap<K, V>(initialCapacity, loadFactor);
    }

    public static <K, V> WeakHashMap<K, V> newWeakHashMap(
            final Map<? extends K, ? extends V> m) {
        return new WeakHashMap<K, V>(m);
    }
}

Related Tutorials