什么时候在java,运行时或编译时加载静态变量? [英] when is static variable loaded in java, runtime or compile time?

查看:61
本文介绍了什么时候在java,运行时或编译时加载静态变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时加载静态变量,运行时或编译时?有人可以解释一下。

When is static variable loaded, runtime or compile time? Can someone please explain it.

我真的很感谢帮助。

谢谢。

推荐答案

它们在运行时加载。

静态意味着:变量属于类,而不属于类的实例。因此,每个静态变量只有一个值,如果你有n个类的实例,则不是n个值。

Static means: that the variable belong to the class, and not to instances of the class. So there is only one value of each static variable, and not n values if you have n instances of the class.

这篇关于什么时候在java,运行时或编译时加载静态变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆