When should we call System.exit in Java

In Java, What is the difference with or without System.exit(0) in following code?

public class TestExit
{      
    public static void main(String[] args)
    { 
        System.out.println("hello world");

        System.exit(0);  // is it necessary? And when it must be called? 
    }      
}

The document says: “This method never returns normally.” What does it mean?

10 Answers
10

Leave a Comment