I have a MyConstants class, which holds company name, etc. Everything in it has been defined as public static final. Now I'd like to add some assignment statements that may as well be static. Something like initNames below:
public class MyConstants
public static final String names;
public static final int BOB_INDEX = 0;
public static final int ALICE_INDEX = 2;
public void initNames()
names[BOB_INDEX] = "Bob";
names[ALICE_INDEX] = "Alice";
But currently, I never actually instantiate the MyConstants class. Therefore, even if I put these new assignment statements in the MyConstants class constructor, it does no good--because it never get's constructed.
I have a vague recollection of how to solve this--something about static methods called at class-load time. Am I making that up? Is there a way to have this method run (once) without explicitly calling it somewhere?