Check out example codes for "java quit program". It will help you in understanding the concepts better.

Code Example 1

System.exit(0);

Code Example 2

public static void main(String... str) {
    System.out.println(1);
    return;
    System.out.println(2);
    System.exit(0);
}

Learn ReactJs, React Native from akashmittal.com