Static
static method
static method指的是Class的方法,而不是instance的方法
public class Patterns {
public static Map<String, String> patternsMap;
static {
patternsMap = new HashMap<>();
patternsMap.put("OTHER", ".");
....
}
static String find(String key) {
return patternsMap.get(key);
}
}
static class
static class can only be defined in a inner Class, e.g.
public class OuterClass {
public static class InnerClass{
InnerClass(){
System.out.println("============= static 内部类 InnerClass =============");
}
}
}
public class TestStaticClass {
public static void main(String[] args) {
// 不需要new一个OutClass
new OuterClass.InnerClass();
}
}
标签:InnerClass,Java,class,patternsMap,Class,static,public
From: https://www.cnblogs.com/attack204/p/16861936.html