What is the difference between using the lowercase keyword enum and the uppercase class name Enum to define a class?
public enum Apple {
RedDelicious, GrannySmith;
}
public Enum Pony {
Earth, Pegasus, Unicorn
}
The second version is not correct anyway, as I am not familiar with the correct syntax of that method of creating Enums, but apparently, something similar is possible.
My apologies if this question seems as though it lacks research effort, but that is not the case; due to the casing issue, this information is not easy to find via Google, IMHO.
The enum keyword is part of the Java language. Enum is the name of the Class object that represents an enum; that is, it is the common base class for all enum values. It defines the methods that all enum objects inherit: name(), ordinal(), etc. Think of it like an analogy question from the old SAT: enum is to Enum as class is to Object.
Always use enum in your code for declaring enumerations.
enum is the reserved word used to define a new enumeration.
Enum is an abstract class, that comes with the JDK.
If you want to define a new enumeration, use enum
You can refer to Enum documentation here if you want any further clarification.
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