Solved

Enum Declaration Error

Posted on 2009-05-19
1
2,882 Views
Last Modified: 2013-12-15
I am using Eclipse Platform Version: 3.4.1 and Java build 1.5.0_02-b09. When I try to build the following ENUM declaration code using the eclipse. I am getting the errors listed below the code.

public interface Constant {
    public enum Info {
            private int index;

        Info(int index) {
            this.index = index;
        }

        INFO1(4),
        INFO2(5),
        INFO3(6),
        INFO4(7),
        INFO5(8),
        INFO6(9),
        INFO7(10);
    }
}

Return type for the method is missing
Syntax error on token ",", @ expected
Syntax error on token ",", @ expected
Syntax error on token ",", @ expected
Syntax error on token ",", @ expected
Syntax error on token ",", @ expected
Syntax error on token ",", @ expected
Syntax error on token "INFO1", AnnotationName expected
Syntax error, insert ";" to complete ConstructorDeclaration
Syntax error, insert ")" to complete ConstructorDeclaration
Syntax error, insert ")" to complete SingleMemberAnnotation
Syntax error, insert "}" to complete EnumBody
Syntax error, insert "Identifier (" to complete ConstructorHeaderName
Syntax error, insert "Identifier" to complete EnumConstantHeaderName

Thanks,
Rameshbabu Arjuna Rajan
0
Comment
Question by:arjunarajan
1 Comment
 
LVL 13

Accepted Solution

by:
Bart_Cr earned 300 total points
Comment Utility
Your enums should go before the class body:
public enum Info {     INFO2(5),

        INFO1(4),

        INFO3(6),

        INFO4(7),

        INFO5(8),

        INFO6(9),

        INFO7(10);
 

        private int index;
 

        Info(int index) {

            this.index = index;

        }
 

       }

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 71
count7 challenge 12 66
json example 39 110
Java Jpanels and Jframe 8 19
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

772 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

15 Experts available now in Live!

Get 1:1 Help Now