Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes what is the order of execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is the order of execution" Watch "what is the order of execution" New topic

what is the order of execution

gayathri bhushan
Ranch Hand

Joined: Jan 29, 2001
Posts: 39
i would like to know the order or flow of execution of a java program and an applet when compiling and running...
like it starts with main...and then..
looking forward for a good reply...
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
order is init, start, paint , stop

Val SCJP <BR>going for SCJD
Grant Crofton
Ranch Hand

Joined: Nov 08, 2000
Posts: 154
An application just does main().
Not sure about compilation, though.
Graeme Brown
Ranch Hand

Joined: Oct 13, 2000
Posts: 193
The applet lifecycle is a bit more complicated than described above.
It is correct that init is called first, then start. After that stop will be called if the browser loses the focus (the user moves to another window) and start will be called when focus is regained. Lastly destroy is called. Paint can be called at any time that the screen area needs to be refreshed, resizing the window or dragging another window over the top etc etc.
To summarise
init() first
then one or more iterations of start() - stop()
finally destroy()
gayathri bhushan
Ranch Hand

Joined: Jan 29, 2001
Posts: 39
thanks to all of you.
It is sorta covered in the JavaRanch Style Guide.
subject: what is the order of execution
Similar Threads
Reg. Action Listener
Please explain the output
filter mapping
Resultset in session
filter mechanism in Servlets