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

  1. Create an enumeration by using the same approach that you use to create a class.
    1. In Studio, right-click a package folder and click the New submenu.
    2. Click Class to create the enumeration class in that package.
    3. Type a name for the enumeration.
    4. In the drop-down list, click Enum.

    Your enumeration looks like:

    package doc.example
    
    enum FruitType {
    
    }
  2. Add your named constants separated by commas:
    enum FruitType {
      Apple, Banana, Orange, Passionfruit
    }
  3. Add constructors, properties, and methods, as required by your business logic.