Enumerations allow you to define a set of constant values that represent the only valid options for a variable. You create an enum by defining a new class that implicitly extends Enum, where you can list the named constants. An enum object can then only hold one of the predefined enum values, precisely defining a new data type with a fixed set of possible values.
Download as RTF, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
10 views
Enumeration Is A List of Named Constants That
Enumerations allow you to define a set of constant values that represent the only valid options for a variable. You create an enum by defining a new class that implicitly extends Enum, where you can list the named constants. An enum object can then only hold one of the predefined enum values, precisely defining a new data type with a fixed set of possible values.
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1
Ennumeration - sometimes you'll want to create a set of constant
values to represent the onlyvalid values for a
variable. This set of valid values is commonly referred to as an enumeration. When you create an enum, you're creating a new class, and you're implicitly extending java . lang. Enum. You can declare an enum as its own standalone class, in its own source file, or as a member of another class.
In its simplest form, an enumeration is a list of named constants that
define a new data type. An object of an enumeration type can hold only the values that are defined by the list. Thus, an enumeration gives you a way to precisely define a new type of data that has a fixed number of valid values. Generics -