Current Forum: Homework 4 General Forum |
Date: Tue Oct 2 2001 11:31 am |
Author: Lee, Peter <petel@cmu.edu> |
Subject: Re: where to put constants? |
|
|
Good questions.
First of all, it is definitely a good idea to have named constants.
Second, you are right in saying that the "static final" modifier is the right way to declare constants. The javac compiler (as well as most other Java compilers) is smart enough to optimize references to such constants.
Finally, it is not possible to declare such named constants outside of a class. Whether you create a separate class for your constants or find appropriate existing classes for them is a matter of style, and in general there is no set rule about this. |
|