We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
为什么在静态方法内调动一个非静态的成员是非法的?
static
一个优先加载的去调用一个还没有加载的当然是非法的了
The text was updated successfully, but these errors were encountered:
还有其他理解吗?
Sorry, something went wrong.
这是我的一点理解,更深层的估计就要翻源码了
同意楼上,另外补充一点:字符串常量池还在堆里,只不过运行时常量在元空间。
No branches or pull requests
问题
为什么在静态方法内调动一个非静态的成员是非法的?
我的理解
static
修饰的成员变量和方法是属于类的,它随着类的加载而加载,随着类的消失而消失static
修饰的普通成员变量是属于类的实例的,也就是对象的,它们只有在类的实例化之后才会被加载总结
一个优先加载的去调用一个还没有加载的当然是非法的了
The text was updated successfully, but these errors were encountered: