【发布时间】:2016-01-14 09:40:55
【问题描述】:
我编写了一个小测试应用程序,如下所示:
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
public class Test extends Application {
public Test() {
System.out.println("first");
}
@Override
public void init() throws Exception {
System.out.println("second");
super.init();
}
@Override
public void start(Stage primaryStage) throws Exception {
System.out.println("third");
Platform.exit();
}
@Override
public void stop() throws Exception {
System.out.println("fourth");
super.stop();
}
public static void main(String[] args) {
launch(args);
}
}
输出是:
first
second
third
fourth
现在,我问自己,使用默认构造函数或 init 方法初始化一些必需的东西之间有什么区别。
谢谢!
P.S.:这个问题与this one 不重复,因为我的问题不处理变量的初始化。我的问题是JavaFX 具体的!
【问题讨论】: