If
class MyClass {
public static void main(String[] str) {
System.out.println("hello world");
}
}
// in some other file and method
Class klass = Class.forName("MyClass");
How can I call MyClass.main
? I do not have the string "MyClass" at compile time, so I cannot simply call MyClass.main(String[]{})
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…