Mega Code Archive

 
Categories / Java / Collections Data Structure
 

Clones a map

import java.util.HashMap; import java.util.Map; public class Main {   /**    * Clones a map.    *    * @param source the source map    * @return the clone of the source map    */   public static Map copy(Map source) {       if(source == null) {           return null;       }       Map result = new HashMap();       result.putAll(source);       return result;   } }