object is to class as enum is to ...?
I'm using C# but I'd like the answer for Java as well, if there is one.
Thank you, as always.
I'm using C# but I'd like the answer for Java as well, if there is one.
Thank you, as always.
In Java, Enum is now a type of class, so you can have an enum object.
"Enum is to Value Type"
Enums are strongly typed constants
In the C# tradition, they are strongly typed, meaning that an enum of one type may not be implicitly assigned to an enum of another type even though the underlying value of their members are the same.
Enums are value types, which means they contain their own value, can't inherit or be inherited from, and assignment copies the value of one enum to another.
Enums are used and referred to with both lower case, enum, and upper case, Enum. The relationship between the two is that the C# type, enum, inherits the Base Class Library (BCL) type, Enum. Use the C# type, enum, to define new enums and use the BCL type, Enum, to implement static enum methods.
Source: http://www.csharp-station.com/Tutorials/Lesson17.aspx
It doesn't matter whether we're discussing C# or Java, the sentence cannot be completed the way you expect it to, because of the following fundamental flaw in it: both enum and class are types, whereas an object is a particular instance of a type.
In C#, an enum is a value type that restricts an underlying numeric type by defining acceptable values and (optionally) combinations of those values for the underlying type. Given the following example:
enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };
we say that Days is an enum, while Monday is one of its values.
In Java, an enum is a class defined using special syntax that defines unique, distinguished, publicly accessible instances of it. An enum is final, i.e. it cannot be extended.
An Object is an instance of a class. enum is an example of a keyword.