This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes variable CONSTANT? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "variable CONSTANT?" Watch "variable CONSTANT?" New topic
Author

variable CONSTANT?

calvinho
Greenhorn

Joined: Mar 11, 2001
Posts: 10
How can I assign the value of a CONSTANT at run-time? What I mean is the value of the CONSTANT will be dependent of some other factors which may not be known at compile time.
To cite an example, I want to assign a value to a CONSTANT which depends on the platform on which the program runs...
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
JavaRanch has a Naming Policy Please reregister with a proper name.
By CONSTANT I assume you mean a final variable. A final variable can be assigned in a couple of ways. The most common is direct assignment at declaration.

If it is a member variable, and you don't assign it at declaration time, then you are required to assign it in all constructors.

If it is a class variable, and you don't assign it at declaration time then you have to assgin it in a static initializer block.

------------------
Hope This Helps
Carl Trusiak, SCJP2
[This message has been edited by Carl Trusiak (edited July 30, 2001).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variable CONSTANT?