hank1
asked on
constant expression required
UPdate to below question. See the bug report on sunsite. So if this is correct, how
does one create a shorthand reference to a long class name?
Some more changes?
got javac message "constant expression required" for
---file
public class A {
A() {
cmd = new CommandCodes();
}
.... code
switch(int) {
case cmd.typeID: ... code;
}
--- file
public final class CommandCodes {
public final static int typeID = 1;
}
Seems this is as constant as it gets. What's with the new release 1.3?
does one create a shorthand reference to a long class name?
Some more changes?
got javac message "constant expression required" for
---file
public class A {
A() {
cmd = new CommandCodes();
}
.... code
switch(int) {
case cmd.typeID: ... code;
}
--- file
public final class CommandCodes {
public final static int typeID = 1;
}
Seems this is as constant as it gets. What's with the new release 1.3?
ASKER
so why not
public final cmd = new CommandCodes();
public final cmd = new CommandCodes();
Your code should be
switch(CommandCodes.int) {
case cmd.typeID: ... code;
}
'int' is not a final in the scope of just the class A since int is defined to be a constant in its inner class.
>. See the bug report on sunsite. So if this is correct, >how does one create a shorthand reference to a long class >name?
I dont quite get what you are referring to.
Padma.
switch(CommandCodes.int) {
case cmd.typeID: ... code;
}
'int' is not a final in the scope of just the class A since int is defined to be a constant in its inner class.
>. See the bug report on sunsite. So if this is correct, >how does one create a shorthand reference to a long class >name?
I dont quite get what you are referring to.
Padma.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for such a detail. Interesting that you mention interface... it died on me too in 1.3.
thats why you get this error.
place in your code some final variables for the number you know you can get if there are only few of them.
and this will solve the problem