File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variable CONSTANT?

 
calvinho
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic