| Author |
what is the difference between final, static, and final static.
|
kasthala kasturi
Greenhorn
Joined: Dec 20, 2006
Posts: 3
|
|
Hello All, can anyone answer to this question.I know what static member does,and final member does.But please anyone tell me what is the use of declaring final static to a member.Thank you in advance.
|
 |
Rajkamal Pillai
Ranch Hand
Joined: Mar 02, 2005
Posts: 434
|
|
IMHO final - Makes the member value be constant (cannot be changed). static - All instances of a class share the member. I'd say, final + static - All instances of the class share the member and its value cannot be changed. Hope this helps and answers your question? -Raj.
|
 |
Edwin Dalorzo
Ranch Hand
Joined: Dec 31, 2004
Posts: 961
|
|
If you refer to static member variables, then the final keywork is used to create constants. The variable belongs the class and cannot be altered, therefore it is considered a constant. If you refer to static member methods, the final keyworkd avoid that other classes in the hierachy shadow the original method declaration. You know that static members are not inherited, therefore static methods are not inherited either. But a subclass could shadow a static method declaration in the parent class, unless the static method is declared final.
|
 |
 |
|
|
subject: what is the difference between final, static, and final static.
|
|
|