- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java.lang.System.exit() Method
Description
The java.lang.System.exit() method terminates the currently running Java Virtual Machine.
The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
Declaration
Following is the declaration for java.lang.System.exit() method
public static void exit(int status)
Parameters
status − This is the exit status.
Return Value
This method does not return any value.
Exception
SecurityException − if a security manager exists and its checkExit method doesn't allow exit with the specified status.
Example
The following example shows the usage of java.lang.System.exit() method.
package com.tutorialspoint; import java.lang.*; public class SystemDemo { public static void main(String[] args) { int arr1[] = { 0, 1, 2, 3, 4, 5 }; int arr2[] = { 0, 10, 20, 30, 40, 50 }; int i; // copies an array from the specified source array System.arraycopy(arr1, 0, arr2, 0, 1); System.out.print("array2 = "); System.out.print(arr2[0] + " "); System.out.print(arr2[1] + " "); System.out.println(arr2[2] + " "); for(i = 0;i < 3;i++) { if(arr2[i] > = 20) { System.out.println("exit..."); System.exit(0); } else { System.out.println("arr2["+i+"] = " + arr2[i]); } } } }
Let us compile and run the above program, this will produce the following result −
array2 = 0 10 20 arr2[0] = 0 arr2[1] = 10 exit...
java_lang_system.htm
Advertisements
To Continue Learning Please Login
Login with Google