which is executed first?
package
staticinstanceflow;
public class Test {
{
System.out.println("First
instance block");
}
static
{
System.out.println("First
static block");
}
Test()
{
System.out.println("Constructor");
}
public static
void main(String[] args) {
Test
t1=new
Test();
System.out.println("main");
Test
t2=new
Test();
}
static
{
System.out.println("Second
static block");
}
{
System.out.println("Second
instance block");
}
}
o/p-----------------------------
First static block
Second static block
First instance block
Second instance block
Constructor
main
First instance block
Second instance block
Constructor
No comments:
Post a Comment