Java – Terminate application by code

Java application can be stop or terminate by exit of system.

Exit can terminate the running java application. All process will be terminated if exit state come with zero

0 used to terminate application forcefully

-1 used to terminate application if error is found

public class ExitProgram {
    public static void main(String[] args) {
        System.out.println("Before exit");

        System.exit(0);// this exit is used to terminate the java application

        System.out.println("After exit");
    }
}
Bookmark  

 

Leave a Reply

Security Code:

 

  Random Post