Solved

Enum Declaration Error

Posted on 2009-05-19
1
2,956 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

761 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