Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java : Error in Enum Declaration Saying Misplaced Constructors

Tags:

java

I may get result of any of the type , so i am defining enum this way

public enum Result 
     {
        1, 2,3, 4,5, 6,7, 8
     }


String resultvalue = calculateResult();

    switch (Result .valueOf(resultvalue ))
          {

          }

But i am geting error at the Enum Declaration itself saying Mispalced Constructors .

Could anybody please help me

like image 579
Gajjini Avatar asked Jul 01 '26 18:07

Gajjini


2 Answers

Those aren't valid identifiers for enum values, basically. You'll need to prefix them with a letter or _. You'll also need to make the identifiers unique - currently you've got 0010 four times...

Once you've sorted that out, the rest should probably be okay - but if you have any more problems, please post a short but complete program, rather than snippets.

like image 131
Jon Skeet Avatar answered Jul 04 '26 06:07

Jon Skeet


0001 is not a valid Java identifier. A Java Identifier must not start with a digit.

like image 27
Joachim Sauer Avatar answered Jul 04 '26 06:07

Joachim Sauer