• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initialization sequence

 
Asif Iqbal
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all!

Can anyone one explain me initailization sequence i.e. for

static variable
static block
static method
constructors
instance variable
instance block
instance method

and same for super class if we instansiate a subclass's object.
What can we use as Constroctor's body?

thanks
 
Sid Murrey
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


When run, the following output is produced:



Local variables in static and non-static methods are of course only initialized when the method is called.
The order of execution of static blocks and static variable initialization is depending on the code, as far as I know!
[ July 23, 2008: Message edited by: Sid Murrey ]
 
Joe Harry
Ranch Hand
Posts: 10112
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way if for you to simply try it for yourself!
 
Raphael Rabadan
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

there is a interesting topic about it on the 2nd page, take a look at it: http://www.coderanch.com/t/269520/java-programmer-SCJP/certification/initialization-sequence
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic