Java System exit() MethodLast Updated : 17 Mar 2025 The 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 1Output: array[0]=9 array[1]=8 array[2]=7 array[3]=6 terminatingjvm,exiting Example 2Output: 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-gc-method |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India