Re: Public Static Final
- From: Liz <liz@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 31 Mar 2007 22:13:47 +0100
On 31 Mar 2007 12:57:55 -0700, Sandy wrote:
I have a series of values which I want to use as constants. I want
them to be constants useable throughout my application, not just a
single class.
I thought that if I declared them 'Public Static Final int X = 1' then
from all classes I could access X.
Ie: in class Barney I use:
Public Static Final int STRENGTH = 1;
then in class Fred I could say:
if(type == STRENGTH)
{
// do stuff
}
In my case I get the error: cannot find symbol variable STRENGTH.
I am obviously doing it incorrectly.
How SHOULD I declare my public constants that I want to use
application wide?
Thanks.
Use the class name before the constant name when you reference it from
another class:
if (type == Barney.STRENGTH)
{
etc.
(And I am sure you had lower case letters starting public static and
final.)
.
- References:
- Public Static Final
- From: Sandy
- Public Static Final
- Prev by Date: Public Static Final
- Previous by thread: Public Static Final
- Index(es):
Relevant Pages
|
|