It's not a secret anymore!*
The moose likes Beginning Java and the fly likes instance block is called first or constructior called first 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 "instance block is called first or constructior called first in java" Watch "instance block is called first or constructior called first in java" New topic
Author

instance block is called first or constructior called first in java

Ramakrishna Gummadi
Greenhorn

Joined: Jun 29, 2011
Posts: 16
instance block is called first or constructor is called first in java
Sandeep Kumar B
Ranch Hand

Joined: Jul 10, 2011
Posts: 41
Instance block
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Which you could have tried yourself by simply implementing it.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ramakrishna Gummadi
Greenhorn

Joined: Jun 29, 2011
Posts: 16
Sandeep Kumar B wrote:Instance block

I mean is instance block called first or constructor called first ?

actually i heared dat.. if a instance block and constructor in a class... then while we creating object to that class.. constructor wil called. now before constructor execution, constructor wil call and execute the instance block, then constructor executes... is this right >?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37940
    
  22
Go through the Java™ Language Specification index and look for "order" with ctrl-F. This is one of the hits, which I hope you will find useful. If not, try again with ctrl-F "order"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: instance block is called first or constructior called first in java
 
Similar Threads
Initilization block
Instance initialization block error
Constructor
Static Initialization Block
Initialzer's