Java System exit() MethodThe exit() method of System class terminates the current Java virtual machine running on system. This method takes status code as an argument.
SyntaxParameterstatus - It is the exit status. ReturnsThis method does not return any value. ExceptionIf security manager exist and his checkexit method doesn't approve exit with specified status then a SecurityException is thorwn. Example 1Test it NowOutput: array[0]=9 array[1]=8 array[2]=7 array[3]=6 terminatingjvm,exiting Example 2Test it NowOutput: program will terminate when i is 1 your no is 10 your no is 9 your no is 8 your no is 7 your no is 6 your no is 5 your no is 4 your no is 3 your no is 2 your no is 1 Value is 1 now terminating your program
Next TopicJava System
|