Enum type is a type which consist of fixed set of constant fields. like direction and days includes values NORTH, SOUTH, EAST, and WEST and SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY and SATURDAY respectively.
Enum type is a type which consist of fixed set of constant fields. like direction and days includes values NORTH, SOUTH, EAST, and WEST and SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY and SATURDAY respectively.Enum type is a type which consist of fixed set of constant fields. like direction and days includes values NORTH, SOUTH, EAST, and WEST and SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY and SATURDAY respectively. Since they are constants so we are taking these values into the uppercase letters.
Lets take an example of enum data types:
EnumTestResult.java
public class EnumTestResult {
|
DaysOfWeek.java
public enum DaysOfWeek {
|
Here is the Output:
C:\Documents and Settings\compaq 20\Desktop\Tutorials>java EnumTestResult Mondays are working days. Midweek days are so-so. Midweek days are so-so. Weekends are best. Weekends are best. |
 
Ads