mapfactory.java
来自「java 的源代码」· Java 代码 · 共 40 行
JAVA
40 行
package com.reddragon2046.base.utilities.data.util;
import java.util.Map;
public class MapFactory
{
public MapFactory()
{
}
public static Map create(Class mapClass)
{
try
{
return (Map)mapClass.newInstance();
}
catch(Exception e)
{
throw new RuntimeException("error creating Map of type " + mapClass + ":" + e.getLocalizedMessage());
}
}
public static Map create(Class mapClass, Object values[])
{
Map map = create(mapClass);
for(int i = 0; i < values.length; i++)
map.put(new Integer(i), values[i]);
return map;
}
public static Map createCopy(Map m)
{
Map copy = create(m.getClass());
copy.putAll(m);
return copy;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?