?
Solved

Enum Declaration Error

Posted on 2009-05-19
1
Medium Priority
?
3,007 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
Bart Cremers earned 1200 total points
ID: 24419884
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

765 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