My enum file looks like this:
My application class basically asks users to enter a genre and then uses an instance to add objects inside an arraylist. Following is the part of code which asks the users to enter the genre and then add:
However every time after I run the application and the 'Enter Genre' shows up in the console, the following errors are printed before I can even type in the enum.
Exception in thread "main" java.lang.IllegalArgumentException: No enum constant part01.Genre.
at java.base/java.lang.Enum.valueOf(Enum.java:273)
at part01.Genre.valueOf(Genre.java:3)
I used the code without using toUpperCase earlier but still had the same errors. I'm really having a hard time figuring out why is this error being caused.
Can someone guide me about this?