Create an enumeration
An enumeration provides a fixed set of values that you can use for a property or variable. For example, a FruitType enumeration provides names of fruits.
Procedure
-
Create an enumeration by using
the same approach that you use to create a class.
- In Studio, right-click a package folder and click the New submenu.
- Click Class to create the enumeration class in that package.
- Type a name for the enumeration.
- In the drop-down list, click Enum.
Your enumeration looks like:
package doc.example enum FruitType { } -
Add your named constants separated by commas:
enum FruitType { Apple, Banana, Orange, Passionfruit } - Add constructors, properties, and methods, as required by your business logic.
