9 How ".class" file is loading by Object creation


Suppose we have two file Demo.java and Loading.java

Demo.java

class Demo{
static{
System.out.println("Static Block Demo");
}
}


Loading.java

public class Loading{

public static void main(String...r)throws Exception{
new Demo();//Unreferenced Object
//Anonymous Object or Unused object
}
}

By Executing Loading  we loaded all static data.


Previous
Next Post »