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.
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.
相关文章推荐
- What’s the difference between an interface and an abstract class in Java?
- What is the difference between a soft reference and a weak reference in Java?
- What is the difference between @staticmethod and @classmethod in Python?
- The difference between scheduleAtFixedRate and scheduleWithFixedDelay in JAVA
- what is the difference between static and normal variables in c++
- What's the difference between Future and FutureTask in Java?
- Difference between transient and volatile keyword in Java
- Difference between Stack and Heap in Java
- Difference between HashSet and HashMap in Java
- 数据插入difference between count(*) and count(col) in the query
- The difference of overriding between C# and Java
- Difference between Vector and ArrayList in java?
- What is the difference between getWidth/heigth() and getMeasuredWidth/Heigth() in Android SDK?
- Difference between ArrayList and LinkedList in Java
- What are the differences between a pointer variable and a reference variable in C++?
- [ReadingNotes] Search the links, static final in the java
- In Java, what's the difference between public, default, protected, and private?
- The Similarities and Differences Between C# and Java -- Part 1(译)
- Difference between Externalizable and Serializable in Java
- Difference between ArrayList and Vector in Java