您的位置:首页 > 编程语言 > Java开发

static field and method in java

2015-06-04 11:26 465 查看
Called
class members
:
class attributes
and
class methods
.

We can use
ClassName.StaticField
and
ClassName.StaticMethod
to access them.

They don’t belong to any instance, so we can’t use
this.StaticMember
,
super.StaticMember
.

Note:
main
method is static, so JVM doesn’t create a instance of the class where
main
is in. As a result,
main
can’t access non-static members of the class unless create instance of that class.

static block: when the class is loaded, the static block in that class is executed, and executed for only one time. Usually used to initialized the class.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java