System.exit(): This method is available in java.lang.System class of Java.
Syntax:
void java.lang.System.exit(int status)
This method takes one argument of type int as its parameter. This method terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
Parameters: One parameter is required for this method.
status: exit status.
Throws:
SecurityException - if a security manager exists and its checkExitmethod doesn't allow exit with the specified status.
Approach
Java
public class Systemexit {public static void main(String[] args) {int status = 0;System.out.println("Before exit " + System.console());System.exit(status);System.out.println("After exit " + System.console());}}
Output:
Before exit null
No comments:
Post a Comment