public enum AnnotationType
{
static
{
AnnotationType[] arrayOfAnnotationType = new AnnotationType[9];
AnnotationType CIRCLE;
arrayOfAnnotationType[0] = CIRCLE;
AnnotationType FREETEXT;
arrayOfAnnotationType[1] = FREETEXT;
AnnotationType HIGHLIGHT;
arrayOfAnnotationType[2] = HIGHLIGHT;
AnnotationType INK;
arrayOfAnnotationType[3] = INK;
AnnotationType LINE;
arrayOfAnnotationType[4] = LINE;
AnnotationType NOTE;
arrayOfAnnotationType[5] = NOTE;
AnnotationType SQUARE;
arrayOfAnnotationType[6] = SQUARE;
AnnotationType STRIKETHROUGH;
arrayOfAnnotationType[7] = STRIKETHROUGH;
AnnotationType UNDERLINE;
arrayOfAnnotationType[8] = UNDERLINE;
AnnotationType[] ENUM$VALUES = arrayOfAnnotationType;
}
这里我得到语法错误插入“Identifier”来完成Enum Constant Header。如何纠正这个......
}
答案 0 :(得分:3)
这不是你申报枚举的方式。你通常有:
public enum AnnotationType
{
CIRCLE, FREETEXT, HIGHLIGHT, INK, LINE, NOTE, SQUARE,
STRIKETHROUGH, UNDERLINE;
}
...虽然可以创建自己的构造函数并将数据传递给它,等等。
这看起来好像你基本上试图重新编译反编译器的输出。你为什么需要这样做?
答案 1 :(得分:2)
Jon Skeet是对的,但这也会对数组做出你想做的事情:
AnnotationType[] arrayOfAnnotationType = AnnotationType.values();
答案 2 :(得分:1)
反编译能力差!!!
public static enum AnnotationType
{
CIRCLE,
FREETEXT,
HIGHLIGHT,
INK,
LINE,
NOTE,
SQUARE,
STRIKETHROUGH,
UNDERLINE,
}
public AnnotationType[] arrayOfAnnotationType = AnnotationType.values();
public AnnotationType[] ENUM$VALUES = arrayOfAnnotationType;
最后两个......只有你需要数组???