public static final - compilation error



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
.



Relevant Pages

  • Re: public static final - compilation error
    ... Kamil Roman wrote: ... public class Stale {public static final String[] OPERATORS = new String{ ... public static int MULTI; //final ...
    (comp.lang.java.help)
  • Cannot find symbol variable number?
    ... error message "Cannot find symbol variable number". ... Scanner input = new Scanner; ... public static int getNumber{ ...
    (comp.lang.java.programmer)