java ENUM error when using jdk 1.5

Posted on 2008-11-04
Last Modified: 2010-04-21
I got some sample code and when I try to compile it I get the following errors. Any ideas how I can fix them


---------------------------------------------------------------------------------------------------------- as of release 1.5, 'enum' is a keyword, and may not be
used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
    public static int getIntEnumVal(String enum) {
                                           ^ as of release 1.5, 'enum' is a keyword, and may not be
used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
        return Integer.parseInt(HTTPHelper.getEnumerationValue(enum));                                                              ^

Question by:anshuma
    LVL 20

    Accepted Solution

    Rename your variable from enum to something else
    enum is an identifier for the new enum type from 1.5 up so you cannot use it as a regular name for a variable

    public static int getIntEnumVal(String enum) {
    should be
    public static int getIntEnumVal(String enum1) { //for example
    and then change all references in the method itself
    LVL 12

    Assisted Solution

    What said by Venabili is correct.
    Following is the extra information. If it is OK to compile with javac 1.4 then you can try the following option to overcome the above error without changing the enum variables references in the code.
    javac -source 1.4 <>

    Author Closing Comment

    You guys are awesome. Thanks a ton

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now