java作业题求救!!!thinking in java第7章课后第22题
Prove that class loading takes place only once. Prove that loading may be caused by either the creation of the first instance of that class, or the access of a static member.
该如何证明啊??我不懂啊~~loading过程是如何体现的呢??是不是新建一个对象,然后用构建器中的显示语句来实现啊?我那样做却显示了多个啊..汗..还有那个访问静态成员该如何做啊??下面是我编的代码...显示的不对啊...汗...
final class Amphibian{
static int i=1;
Amphibian(){
System.out.println("constructor");
}
static void ptr(){
System.out.println("ok");
}
}
public class myjava{
public static void main(String[] args){
System.out.println(i);
Amphibian f2= new Amphibian();
Amphibian f1= new Amphibian();
}
}