-1
我在这里有两个文件,在StaticSuper类(文件2)中,StaticSuper方法似乎有一个命名clonflict。为什么是这样?在类文件中命名冲突
public class StaticTests extends StaticSuper {
static int rand;
static {
rand = (int) (Math.random() * 6);
System.out.println("static block " + rand);
}
StaticTests() {
System.out.println("constructor");
}
public static void main(String [] args) {
System.out.println("in main");
StaticTests st = new StaticTests();
}
}
class StaticSuper {
static {
System.out.println("Super static block");
}
//naming conflict here
StaticSuper{
System.out.println("super constructor");
}
}
这是否意味着一个构造函数? –
@SotiriosDelimanolis通过System.out.println(“超级构造函数”)判断;'我认为我们可以安全地假设:是的。它看起来像简单的印刷问题(在构造函数声明中缺少'()')。 – Pshemo
您忘记了构造函数声明中的括号。 –