您的位置:首页 > Web前端

the difference between final and static in java

2012-03-20 13:23 465 查看
     static modifier
keyword can be modified with variable
and block as well as
class method: When
you define a static
variable, jvm will
be allocated in
the memory heap,
All Programs, a reference to it
will point to
this address without the need to re-allocate memory;
modification of a
block of time
(the code written in
the static block
static {...})
when the virtual machine
will give priority to
load code, which
is mainly used for system initialization;when
modification of a
method you can
directly through the class to call
without the need for a new
object.

   The final can be modified
variables, methods and classes,
when you define
a final variable,
the jvm will be assigned
to the constant
pool, the program can
not change its
value; when you define
a method to change
the method in a subclass
will not be re-write;
when you modify
a class, the class
can not be inherited.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息