A Slice enumeration maps to the corresponding enumeration in Java. For example:

{zcode:slice}
enum Fruit { Apple, Pear, Orange };
{zcode}

The Java mapping for Fruit is shown below:

{zcode:java}
public enum Fruit implements java.io.Serializable {
    Apple,
    Pear,
    Orange;

    // ...
}
{zcode}

Given the above definitions, we can use enumerated values as follows:

{zcode:java}
Fruit f1 = Fruit.Apple;
Fruit f2 = Fruit.Orange;

if (f1 == Fruit.Apple) // Compare with constant
    // ...

if (f1 == f2)                     // Compare two enums
    // ...

switch (f2) {             // Switch on enum
case Fruit.Apple:
    // ...
    break;
case Fruit.Pear
    // ...
    break;
case Fruit.Orange
    // ...
    break;
}
{zcode}

Note that the generated class contains a number of other members, which we have not shown. These members are internal to the Ice run time and you must not use them in your application code (because they may change from release to release).

See Also