System.exit() Java Method

System.exit() Java Method

java.lang.System.exit() methods stops running or terminates Java program by shutting down Java virtual machine.
This method takes a status code.There are different state where a negative value means abnormal program termination.

exit(0)-is successful termination.
exit(-1) or any other negative value shows unsuccessful termination.This method is void and has no return type.

Syntax:
public void exit(int status)
[
import java.util.*;
import java.lang.*;

public class ExitMethodExample {

    public static void main(String[] args)
    {
        int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};

        for (int i = 0; i < arr.length; i++)
        {
            if (arr[i] >= 5)
            {
                System.out.println("exit...");

                // Terminate JVM                System.exit(0);
            }
            else                System.out.println("arr["+i+"] = " +
                        arr[i]);
        }
        System.out.println("End of Program");
    }
}
]

Output:
run:
arr[0] = 1
arr[1] = 2
arr[2] = 3
arr[3] = 4
exit...
BUILD SUCCESSFUL (total time: 3 seconds)

See also:

System.in Java Method Example

COMMENTS

Name

android android Apps android emulators antivirus blogger bluestack Break Statement in Java constructors download downloader drivers emulators java java control statements java do-while loop java for loop java infinitive do-while loop java system methods java tutorials Java While Loop java.awt java.swing javalookandfeel javascript JButton JCheckBox JColorChooser JComboBox JDialog JFileChooser JFrame JLayeredPane JList JMenuBar joomla JOptionPane JPanel JPasswordField JPopupMenu JProgressBar JRadioButton JScrollBar JSlider JSpinner JTabbedPane JTable JTextArea JTextField JToolBar mysql php plugins Polymorphism setToolTiptext skype for windows software swing class themes Visual Studio Code WeChat whatsapp wordpress
false
ltr
item
Java Codes: System.exit() Java Method
System.exit() Java Method
System.exit() Java Method
Java Codes
http://www.download-all.net/2017/02/systemexit0-java-method.html
http://www.download-all.net/
http://www.download-all.net/
http://www.download-all.net/2017/02/systemexit0-java-method.html
true
7826648292785071009
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy