Joan said:
My book says that if you execute "System.exit(0);" that it does an exit
without doing anything else.
Books often skip details and advanced information to keep down the size
and focus on the basics. Once you have the basic concepts, use the API
Javadocs and Java Language Specification to fill in missing details.
The System.exit documentation indicates that System.exit(n) is
effectively equivalent to Runtime.getRuntime().exit(n).
The documentation for exit in Runtime says:
"The virtual machine's shutdown sequence consists of two phases. In the
first phase all registered shutdown hooks, if any, are started in some
unspecified order and allowed to run concurrently until they finish. In
the second phase all uninvoked finalizers are run if
finalization-on-exit has been enabled. Once this is done the virtual
machine halts."
It is also described as throwing "SecurityException - If a security
manager is present and its checkExit method does not permit exiting with
the specified status" so the exit is conditional.
This is the same as "exit without doing anything else" in many cases,
but not all. This type of simplification is typical of many books, and
harmless as long as readers understand that the book is not telling the
whole story, and know where to look for more data.
Patricia