Heck, I only get frisky with perceived slights. ;-) I think something is wrong with this Eddie. Try the following two classes and interface and you will fidn that if you (1) compile all three, then change the Xs in the constants to Ys and recompile only the TestClass, you will get all Ys in all cases. So, the static block makes no difference, as it shouldn't because it is only an easy way to write the code and has no independent significance that I know of, and whether you have an interface or a class makes no difference either. Perhaps there will be a difference if you extend the ClassConstant or implement the InterfaceConstant or put the constant classes in a different directory. Hmm, I'll try that.
Nope, I change the package for the constant class and interface to test.sub and that still made no difference. I am not sure why this is happening, because I know that I have to recompile constants every time I change them. I do this as a matter of course. I expected you would be right. The classes are. package test.sub; public class ClassConstant { public static final String BAR_SOME = "barSomeX"; public static final String BAR_NONE; static { BAR_NONE = "barNoneX"; } } package test.sub; public class InterfaceConstant { public static final String BAR_SOME = "barSomeX"; public static final String BAR_NONE; static { BAR_NONE = "barNoneX"; } } package test; import test.sub.ClassConstant; import test.sub.InterfaceContant; public class TestClass { private String someC = ClassConstant.BAR_SOME; private String noneC = ClassConstant.BAR_NONE; private String someI = InterfaceConstant.BAR_SOME; private String noneI = InterfaceConstant.BAR_NONE; public String toString() { return "\nsomeC = " + someC + "\n" + "noneC = " + noneC + "\n" + "someI = " + someI + "\n" + "noneI = " + noneI; } public static void main(String [] params) { System.out.println(new TestClass()); } } On Sun, 23 Jan 2005 16:06:42 -0600, Eddie Bush <[EMAIL PROTECTED]> wrote: > Not to start another holy war, but perhaps you all could help me > either solidify or dispell something I learned ... > > I've always been of the impression that mentioning a value for a > startic final member is poor form, and that this should always be done > in a static intializer, thus: > > public class Foo { > public static final String bar; > > static { > bar = "baz"; > } > } > > My understanding is that, having called "bar" static final, it will be > inlined and cause things that use Foo to have a compile dependency on > Foo. To clarify, if you build something against Foo, and Foo changes > (bar is now equal to "fee", and not "baz"), you would have to rebuild > for your code to notice the change. Doing things as per above, as I > understand it, keeps this from happening and removes the compile > dependency. > > Have I mis-learned this? This is one huge reason why I would never > consider an interface to implement constants :-) > > Again ... no holy wars, please ;-) > > -- > Eddie Bush > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- ------------------------------ "You can lead a horse to water but you cannot make it float on its back." ~Dakota Jack~ "You can't wake a person who is pretending to be asleep." ~Native Proverb~ "Each man is good in His sight. It is not necessary for eagles to be crows." ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ ----------------------------------------------- "This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation." --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]