java作业题求救!!!thinking in java第7章课后第22题

seraphmk2 2002-02-08 12:58:24
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();
}
}
...全文
87 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧