1 java performance jvm program-entry-point process
class B {
public static void main(String[] args) {
}
}
class A {
public static void main(String[] args) {
B.main(args);
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的流程中,我的 init 方法是 A.main,它依次调用 B.main。
选项2. mains 只是每个类的静态方法,从 A 到 调用时只有一个 JVM 正在运行B.main(args)。
您还可以在 JUNIT 测试中使用它来帮助检查命令行启动行为是否符合预期,例如
@Test void coverage() {
A.main(new String[] { "a","b" }); // or B.main
// assertions here if there is some output state you could check
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64 次 |
| 最近记录: |