The value for annotation attribute Min.value must be a constant expression

前端 未结 1 1842
感情败类
感情败类 2021-01-14 01:15

Eclipse keeps giving me the error:

The value for annotation attribute Min.value must be a constant expression

But I am most definitely givi

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-14 02:05

    The expression

    private static final int MIN_YEAR = Calendar.getInstance().get(Calendar.YEAR) - 1;
    

    will be determined only in run-time, but

    private static final int MIN_YEAR = 2013;
    

    is determined in compilation time, so it's allowed since the values in the annotations should be resolved at compilation time and not runtime.

    0 讨论(0)
提交回复
热议问题