public static final - compilation error
- From: Kamil Roman <mojehasla@xxxxxxxxx>
- Date: Tue, 28 Jun 2005 17:49:11 +0200
Hi,
is it possible to initialize a public static final member of a class in
the class' constructor? I try to do this and I receive error message:
variable PLUS is declared final; cannot be assigned.
The code is:
public class Stale
{
public static final String[] OPERATORS = new String[]
{
new String("+"),
new String("-"),
new String("*"),
new String("/"),
};
public static int PLUS; //final
public static int MULTI; //final
public static int MINUS; //final
public static int DIVIDE;//final
public Stale()
{
for (int i = 0; i < OPERATORY.length; i ++)
{
if(OPERATORY[i].equals("+")) PLUS = i;
if(OPERATORY[i].equals("-")) MINUS = i;
if(OPERATORY[i].equals("*")) MULTI = i;
if(OPERATORY[i].equals("/")) DIVIDE = i;
}
}
}
--
Thanks for help
KR
.
- Follow-Ups:
- Re: public static final - compilation error
- From: Paul
- Re: public static final - compilation error
- From: Thomas Fritsch
- Re: public static final - compilation error
- From: Stefan Schulz
- Re: public static final - compilation error
- Prev by Date: Re: Problems starting jakarta-tomcat 5.5
- Next by Date: Re: public static final - compilation error
- Previous by thread: Calling a Java method from C++ via JNI problem.
- Next by thread: Re: public static final - compilation error
- Index(es):
Relevant Pages
|