returning from main will cause the application to shut down and the JVM to terminate (unless there's other threads running in which case the application will then terminate as soon as those other threads complete).
Originally posted by Oneal Shaha: And neighter the finally block is executed after the return statement in main()(is it right ???) [ August 30, 2004: Message edited by: Oneal Shaha ]
The correct question would not be what happens after the return statement of the main() method, but rather what happens when control moves out of the main() method. A finally block will always be executed before control moves out of the method, just as for any other method. [ August 30, 2004: Message edited by: Mattias Arthursson ]
Adeel, Though we mark a method as void we can always write the simple return statement of syntax " return; ". Also in constructores though void return type also is not allowed. But still we can write the simple return statements in constructores
So after the return statement in 'normal' main method, no object is Garbage collected as the garbage collection thread is a daemon thread.
After main() ends and the jvm terminates, the virtual address space it was running in is either liquidated or made available to the next command/program launched in that address space.
Garbage collection is a fine instrument within the jre that frees up the memory occupied by individual objects during program execution. The operating system's process termination logic just eliminates from memory the jvm and everything that the jvm created as if they never existed in memory.
Also, the jvm shares space in real (hardware) memory and swap/paging disk files. This space is marked available to other processes in the system.
SCJP 1.4, SCWCD in process
Can you shoot lasers out of your eyes? Don't look at this tiny ad: