开发者

problem in declaring enum

开发者 https://www.devze.com 2023-01-11 05:13 出处:网络
public enum ItemType{REFRENCE,ISSUE}; ItemType itemType =IntemType.ISSUE ; int开发者_Go百科 intemNo=0;
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

精彩评论

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