#41 Implementing an Enum Alternative
Write an alternative to Enum, as if before Java 1.5, using some enumerable list as an example,
such as a list of currencies. It is necessary to:
- Have a fixed list of values defined at compile time.
- Have strict typing of values.
- Be able to compare values safely using
==. - Retrieve all values.
- Have an immutable
ordinal, which is the zero-based sequence number in declaration order. - Retrieve values by
ordinal. - Have a value name matching the field name of that value.
- Search by name.
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor