[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

java ENUM error when using jdk 1.5

Posted on 2008-11-04
3
Medium Priority
?
1,227 Views
Last Modified: 2010-04-21
Hi,
I got some sample code and when I try to compile it I get the following errors. Any ideas how I can fix them

thanks
-anshu

----------------------------------------------------------------------------------------------------------

WritebackUtils.java:162: 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) {
                                           ^
WritebackUtils.java:163: 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));                                                              ^




0
Comment
Question by:anshuma
3 Comments
 
LVL 20

Accepted Solution

by:
Venabili earned 1200 total points
ID: 22876257
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
0
 
LVL 12

Assisted Solution

by:basav_com
basav_com earned 800 total points
ID: 22876336
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 <javafile.java>
0
 

Author Closing Comment

by:anshuma
ID: 31513073
You guys are awesome. Thanks a ton
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month18 days, 13 hours left to enroll

834 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