NEWBIE: How to use constructors to fill Static fields?
Posted on 2005-04-15
I have a class that basically just fills in and stores Static fields. The first time it's instantiated, I want the constructor to actually fill in the Static fields (by reading values from a text file, for instance). In subsequent instantiations, I don't want the constructor to do anything. (I just want to get the values of the Static fields...)
Currently, I'm using two different constructors to accomplish this. To distinguish them, one accepts an unused String parameter, and the other has no parameter. This works, but it seems ugly. Is there a more elegant, industry-standard way to accomplish this? I was thinking, for instance, of just checking one of the Static fields for null, and then doing the real initialization...