Java Map Clone clone(Map origMap)

Here you can find the source of clone(Map origMap)

Description

returns a new HashMap containing a shallow clone of the original map.

License

Open Source License

Parameter

Parameter Description
origMap a parameter

Declaration

public static <K, V> HashMap<K, V> clone(Map<K, V> origMap) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**/*  w ww.j a va2s .  co m*/
     * returns a new HashMap containing a shallow clone of the
     * original map.
     * @param origMap
     * @return
     */
    public static <K, V> HashMap<K, V> clone(Map<K, V> origMap) {

        HashMap<K, V> newMap = new HashMap<K, V>();
        if (origMap != null && origMap.size() > 0) {
            newMap.putAll(origMap);
        }
        return newMap;
    }
}

Related

  1. clone(Map aMap)
  2. clone(Map from, Map to)
  3. clone(Map configurationValues)
  4. clone(Map map1)
  5. clone(Map map)
  6. cloneDefaults(Map defaults)
  7. cloneMap(final Map m)
  8. cloneMap(Map map)