Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

java中 static问题

statci{}
和static ss{}

第一种应该是加载这个类的时候就加载,第二种是必须通过这个类的方法调用才加载吧


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

不太能明白你的意思,static{}静态代码块是属于cinit中的,在类初始化的时候执行,static ss{}是属于类方法,在使用class调用时执行。
个人理解:加载这一说怎么理解,如果说是准备好等待执行的话,class在解析阶段就完成了所有准备,等待初始化。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...