free hit counter

Tuesday, July 12, 2005

no magic numbers in Java

Have to say I miss #define and his shady friends. But this is a nifty trick to lose the magic numbers by putting them in an interface.

The key is to have your class implement the interface so you don't have to prepend the class name before the constant. When I have time I'd like to learn how to scope them to the file, and to the package.

Java Tip 5: Java constants


Post a Comment

<< Home