日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

Java System类exit()方法及示例

發布時間:2023/12/1 java 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java System类exit()方法及示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

系統類exit()方法 (System class exit() method)

  • exit() method is available in java.lang package.

    exit()方法在java.lang包中可用。

  • exit() method is used to exit the currently running JVM (Java Virtual Machine).

    exit()方法用于退出當前正在運行的JVM(Java虛擬機)。

  • exit() method is a static method, it is accessible with the class name too.

    exit()方法是靜態方法,也可以使用類名進行訪問。

  • exit() method may be thrown various type of exception and the description of exception are given below,

    exit()方法可能會引發各種類型的異常,下面給出了異常的描述,

    SecurityException: If a particular method checkExit() does not allow exit with the given exit_status when security manager exists in the method.

    SecurityException :如果特定方法checkExit()不允許在方法中存在安全管理器時使用給定的exit_status退出。

Syntax:

句法:

public static void exit (int exit_status);

Parameter(s):

參數:

  • exit_status – represents the stages or level of termination of JVM, and here, the non-zero value represents the abnormal termination of JVM.

    exit_status –表示JVM終止的階段或級別,此處,非零值表示JVM的異常終止。

Return value:

返回值:

The return type of this method is void, it does not return any value.

此方法的返回類型為void ,它不返回任何值。

Example:

例:

// Java program to demonstrate the example of // exit() method of System Classpublic class ExitMethod {public static void main(String[] args) {// declaring an arrayint array[] = {10,20,30,40,50};for (int i = 0; i < array.length; ++i) {if (array[i] < 60) {System.out.println("Element at index" + " " + i + " is " + array[i]);} else {System.out.println("We are exiting JVM normally");System.exit(0);}}} }

Output

輸出量

E:\Programs>javac ExitMethod.java E:\Programs>java ExitMethod Element at index 0 is 10 Element at index 1 is 20 Element at index 2 is 30 Element at index 3 is 40 Element at index 4 is 50

翻譯自: https://www.includehelp.com/java/system-class-exit-method-with-example.aspx

總結

以上是生活随笔為你收集整理的Java System类exit()方法及示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。