一个完整的Java应用程序,通常至少要有一个应用程序的结束点。对于一般程序来说,系统开发者根据需要和个人的偏好,会在程序结束位置,通过添加System.exit(0),或System.out(-1),来结束程序,或不加这些指令,让程序自然运行到结束。
如:下列典型代码
package untitled14;
/**
* This application is to demo how an applcation end
*/
public class Test {
public Test() {
}
public static void main(String[] args) {
Test test1 = new Test();
//.................
System.out.println("hello world");
//Do something before system exit
System.exit(0);//也可以不写这句代码,让程序自然结束。
}
}
|

收藏到QQ书签