Solved

Enum Declaration Error

Posted on 2009-05-19
1
2,910 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 Cremers earned 300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 86
groovy example issue 10 90
JUnit 4 @Before and @BeforeClass differences 3 48
Embarcadero C++ Builder XE10.1 Berlin red arrow Indicator 2 20
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

867 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