不仅仅在main中,任何时候都可以调用的。exit()是一个静态方法,也成为类方法 直接用System.exit();就可以调用。 产生的结果就是结束当前运行的进程。下面是文档中的叙述public static void exit(int status) Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination. This method calls the exit method in class Runtime. This method never returns normally. The call System.exit(n) is effectively equivalent to the call: Runtime.getRuntime().exit(n)
dispose()是一些窗口类的关闭。如Dialog dlg = new Dialog(new Frame()); dlg.diapose()则关闭了对话框
直接用System.exit();就可以调用。
产生的结果就是结束当前运行的进程。下面是文档中的叙述public static void exit(int status)
Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
This method calls the exit method in class Runtime. This method never returns normally. The call System.exit(n) is effectively equivalent to the call: Runtime.getRuntime().exit(n)
dispose()是一些窗口类的关闭。如Dialog dlg = new Dialog(new Frame());
dlg.diapose()则关闭了对话框