Hanya untuk pengingat saja, daripada terus googling
public class TestBlock {
{
System.out.println("This is object block...");
}
public TestBlock() {
System.out.println("This is constructor...");
}
static {
System.out.println("This is static block...");
}
public static void main(String args[]) {
TestBlock obj1 = new TestBlock();
TestBlock obj2 = new TestBlock();
}
}
Hasil :
This is static block...
This is object block...
This is constructor...
This is object block...
This is constructor...
Dari hasilnya, ketahuan urutan eksekusi dan jumlah eksekusi.
Saturday, July 17, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment