This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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.
I agree. Here's the link:
subject: what is the order of execution
It's not a secret anymore!