java中对于initializer的处理方式

    private static final HashMap hm = new HashMap();

    static {
        for (int i = 0; i < 10; i++) {
            hm.put(“test“, “this is value“);
        }
    }

同样的代码,在.net中就可以这么处理,假设class的名字是:Test
private static Hashtable ht;

static Test(){
    ht = new Hashtable();
    for(int i=0;i<10;i++)ht.Add(“test“,“this is value“);
}

原文地址:https://www.cnblogs.com/juqiang/p/6912.html