| Author |
what is the significance of static while declaring constant.
|
kish kumar
Ranch Hand
Joined: Jan 03, 2008
Posts: 54
|
|
what is the significance of static while declaring constant. why java made it implicitly static . suppose if java not made it static it will be available to all objects of class implementing interface with an individual copy. if it is static all objects share common copy. since it is final even though it is not static ,no object can modify it and no harm.so why static really required?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
More of a beginner's question. If it is constant, and intended for use by many instances, why do you want several copies? If the value of BOILING_POINT is always 100, why should each Water object need its own copy? They can share the static field and save memory. It also means that BOILING_POINT is available to other classes without having to create a Water instance.
|
 |
kish kumar
Ranch Hand
Joined: Jan 03, 2008
Posts: 54
|
|
|
Thanks Ritchie
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
You're welcome.
|
 |
 |
|
|
subject: what is the significance of static while declaring constant.
|
|
|