Enumerates the natural domains of a single int value association, based on the enumeration constants in the type of the numeric position, starting from 0 count. All enumerations have a ordinal method that returns the numeric position of each enumerated constant in the type.
Most programs do not require this method and are designed to be used for enumeration-based, generic data structures like Enumset and Enummap.
Instead of exporting the value associated with it based on the ordinal of an enumeration, save it in an instance field.
Public enum Ensemble { SOLO, DUET, TRIO, Quartet, quintet, Sextet, Septet , OCTET, Nonet, Dectet; Public int Numberofmusicians () { return ordinal () + 1; }}
This enumeration represents a different number of musicians. If the enumeration constants are reordered, or if you add an enumeration constant with the same number of musicians as before, there is no way to implement it.
Modified to:
Public enum Ensemble { SOLO (1), DUET (2). TRIO (3), quartet (4), ...; Private Final int Numberofmusicians; Ensemble (int n) { = n; }}
Use the instance domain Numberofmusicians to save the number of musicians.
31st: Replace ordinal with instance field