Prev Next

Java / Enum

Benefits of using Enums in Java.

Enum provides type-safe; Enum variable can be assigned only with predefined enum constants otherwise it will issue compilation error.

Enum can be used in switch-case Java control statement.

Enum has its own namespace.

Enum constants can hold values specified at the creation time.

Enum can help create a Singleton pattern, which is inherently Thread Safe.

Passing Enum as an argument to the static factory method makes method type safe.

More Related questions...

Show more question and Answers...


Comments & Discussions