1

I'm new to Java and trying to setup a switch statement using enums. for the declaration of my enums however I am getting compilation errors such as "illegal start of type", so my question is if names such as are appropriate?

public enum Types
{
 <CD>, <Title>
}
user1623990
  • 25
  • 1
  • 4

1 Answers1

3

No, enum constants, like all Java identifiers, must start with a letter, a currency character ($), or a connecting character (most common being _).

João Silva
  • 89,303
  • 29
  • 152
  • 158
  • 1
    [Interesting question](http://stackoverflow.com/q/11774099/758280) on valid Java identifiers. – Jeffrey Aug 25 '12 at 03:00
  • 1
    Ummm ... you should NOT use the $ character in identifiers in your source code. They are technically legal, but the JLS states that $ is reserved for use by compilers, generators and so on. – Stephen C Aug 25 '12 at 03:30