This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes order of execution in java 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 "order of execution in java" Watch "order of execution in java" New topic

order of execution in java

Hung Chang

Joined: Oct 21, 2001
Posts: 16
hi guys.
what is the order of execution in java.
static variables/blocks, contructor, instance variables/blocks.
static variables/blocks, instance variables/blocks,contructor.
Michael Bruesch
Ranch Hand

Joined: Sep 23, 2001
Posts: 158
When the class is loaded, the static variables/blocks are initialized first. Then when the class is instantiated, the instance variables/blocks are initialized and then the constructor is executed.

Michael J Bruesch<br /><i>I code, therefore I am.</i>
I agree. Here's the link:
subject: order of execution in java
Similar Threads
initialisation sequence
Order of initialization
Static Initializer question
constructor doubt
Need Help