Are static methods always loaded into memory?

吃可爱长大的小学妹 提交于 2019-12-04 14:39:56

Static methods (and non-static methods, and static/member variables) are not loaded into memory directly: the declaring class is loaded into memory in its entirety, including all declared methods and fields. As such, there is no difference in the way that static/non-static methods/fields are loaded.

A class is only loaded by a class loader the first time it is referenced by other code. This forms the basis of the Initialization on demand idiom.

Your class is loaded when (among other conditions) its static method is called for the first time. See reference.

static methods loads only once when you call class.

college="ITS" is an static variable

it happens once you call the class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!