Discussion Board
Go to the previous messageThere are no next messages
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.
Post response

Go to the previous messageThere are no next messages
Current Thread Detail:
where to put constants?      Cipriani, Jason A.      Tue Oct 2 2001 9:41 am       
Re: where to put constants?      Lee, Peter      Tue Oct 2 2001 11:31 am       

Back to previous screen