I have to choose from several types of genres for books and I was thinking using enums for this, but there are several genres composed by two or more words like "Medical, Health & Fitness", "Art & Photography", "Science Fiction", etc.
public enum Genero {
Action, Comedy, Drama, Computers, Novel, Science Fiction
}
But I got a syntax error for "Science Fiction". I tried putting it with double quotes and simple quoutes, but neither worked. This enum is going to be use as a attribute for Book class.
java file may have only one public class. You can therefore declare only one public enum in a . java file. You may declare any number of package-private enums.
The Enum constructor can accept multiple values.
An ENUM column can have a maximum of 65,535 distinct elements.
yes, but you need to know that.
No, it's not possible. Enum names must be valid Java identifiers - that means, no spaces. The usual convention is to declare enum names in all upper-case characters and separate words using an underscore, like this:
public enum Genero {
ACTION, COMEDY, DRAMA, COMPUTERS, NOVEL, SCIENCE_FICTION
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With