On 13 jun, 05:01, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<7e5c63e4-be72-4046-a59f-0559e8c7c...@i31g2000yqm.googlegroups.com>,
"cirudinezid...@gmail.com" <cirudinezid...@gmail.com> wrote:
I have a problem because i want to use an enumeration and get its
constant to create an array of ints,
I have the next code:
public enum ABC {A, B, C};
@Order(values={ABC.A.ordinal(),ABC.C.ordinal(),ABC.B.ordinal()})
public void getProperty(){}
values is declared as an annotation like the follow code:
public @interface Order {
public int[] values();
}
I have an error that says: "The value for annotation attribute
Order.values must be a constant expression"
How can I solve this problem?
I don't see how this can work. As discussed in annotations [1], the
values must be constant expressions [2]. Alternatively, annotations
may be used on enum constants:
public enum ABC { A, B, C };
public @interface Order {
ABC[] value();
}
@Order(value = { ABC.A, ABC.C, ABC.B })
[1]<http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html=