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. |
 
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Enum Data Types View All Comments
Post your Comment