What is Enum in java ?
Enumeration (Enum) in Java was introduced in JDK 1.5
An enum is a special data type that enables for a variable which contains a set of predefined constants. The variable must be equal to one of the values which is predefined for it.
Examples include like days of the week
week (SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY)
user(ADMIN,BROKER,ADVISOR)
Note: All values should be in uppercase letters. Because they are constants, the names of an enum type's fields are in uppercase letters.
we can define an enum type by using the enum keyword. As in below example.
public enum Role{
ADMIN,BROKER,ADVISOR
}
Java enum method?
what are the benefits of enum in java?
Enums are used when we know all possible values at compile-time.
Why enum are used in Java?
How is enum stored in Java?
How are enums stored in memory Java?
How do enums work internally?
How many bits are in an enum?
Why is enum not good?
What is difference between enum and class in Java?
No comments:
Post a Comment