开发者

problem in declaring enum

public enum ItemType{REFRENCE,ISSUE};
    ItemType itemType =  IntemType.ISSUE ;
    int开发者_Go百科 intemNo=0;

I am geting error wheni use above code?why is it so?


  1. The code you provided (still) contains a typo: it's either IntemType or ItemType
  2. Make sure, you use Java 1.5 or later. Earlier versions of Java do not support enums
  3. Make sure, you compile with source level 1.6. It's one of my favourite mistakes in eclipse to use a Java 6 SDK and have a project configured for source level 1.4 ...
  4. Your declaring an interface - an interface can't have fields. Declare it as a class
  5. If none of the above helps - please edit your question and add error details.

Thanks for the comment, from JLS

Every field declaration in the body of an interface is implicitly public, static, and final.


Did you compile with setting "source java 1.5"? The enum syntax was't supported before java 1.5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜