Top.Mail.Ru
July 6th, 2004 - Java developers — LiveJournal
? ?

Java developers

July 6th, 2004
Image

07:10 pm - Imagetrajano - Constants in Interfaces or Classes

I am wondering what people think on where Constants should end up. I found this thread http://www.theserverside.com/discussions/thread.tss?thread_id=19221 and basically ended up answering my own question, but I am not 100% sure if it is valid.

I personally prefer constants in interfaces because its less typing to do. However, if you have non-trivial constants you would generally need a class I think in order to have the static { } initializer. So I would end up using constants in classes just to keep things consistent even if I had to do "public static final" for every single constant. I wish there was a simpler way of doing this without using a code generator which I defined in my blog.
Powered by LiveJournal.com
Image