Java switch statement: Constant expression required, but it IS constant

前端 未结 13 1445
予麋鹿
予麋鹿 2020-11-22 10:42

So, I am working on this class that has a few static constants:

public abstract class Foo {
    ...
    public static final int BAR;
    public static final          


        
13条回答
  •  醉酒成梦
    2020-11-22 11:27

    You get Constant expression required because you left the values off your constants. Try:

    public abstract class Foo {
        ...
        public static final int BAR=0;
        public static final int BAZ=1;
        public static final int BAM=2;
        ...
    }
    

提交回复
热议问题