只有在顶层类中定义,或者在静态内部类中定义,看下面的例子
public class Test {
static void t(){}
class T2{
//!错误,The method a cannot be declared static;
//static methods can only be declared in a static or top level type
//static void a(){}
}
static class T3{
static void a(){}
}
}