国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Java 中的System.exit

2019-11-14 21:18:23
字體:
來源:轉載
供稿:網友
java 中的System.exit

在java 中退出程序,經常會使用System.exit(1) 或 System.exit(0)。

查看System.exit()方法的源碼,如下

 1   /** 2      * Terminates the currently running Java Virtual Machine. The 3      * argument serves as a status code; by convention, a nonzero status 4      * code indicates abnormal termination. 5      * <p> 6      * This method calls the <code>exit</code> method in class 7      * <code>Runtime</code>. This method never returns normally. 8      * <p> 9      * The call <code>System.exit(n)</code> is effectively equivalent to10      * the call:11      * <blockquote><PRe>12      * Runtime.getRuntime().exit(n)13      * </pre></blockquote>14      *15      * @param      status   exit status.16      * @throws  SecurityException17      *        if a security manager exists and its <code>checkExit</code>18      *        method doesn't allow exit with the specified status.19      * @see        java.lang.Runtime#exit(int)20      */21     public static void exit(int status) {22     Runtime.getRuntime().exit(status);23     }

當 status為0 時正常退出程序, 當status為非0數字時異常退出。 終止當前的Java虛擬機。

System.exit()方法返回程序的最頂層, return和它相比是返回上一層。

當程序執行到System.exit()方法后就會停止運行。 如果希望程序遇到System.exit后只退出當前用例,不退出當前程序,可以考慮在異常中做手腳。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 确山县| 师宗县| 鄂尔多斯市| 西丰县| 湖州市| 廊坊市| 宁德市| 呼伦贝尔市| 武隆县| 赫章县| 宁武县| 六盘水市| 水富县| 肃宁县| 会昌县| 汾西县| 微山县| 尉氏县| 曲阳县| 齐齐哈尔市| 乌拉特后旗| 鞍山市| 怀来县| 大邑县| 顺义区| 沾化县| 昭苏县| 读书| 左云县| 金川县| 永福县| 个旧市| 班玛县| 桐庐县| 克什克腾旗| 望谟县| 育儿| 天门市| 高邑县| 利津县| 于都县|