Enums in Java

Enums in Java



  • Enums were introduced in java 5.0
  • Enums restrict a variable to have one of only few predefined values. The values in this enumerated lists are called enums.
  • With the use of enums it is possible to reduce the number of bugs in your code.
  • For Example, if we consider and application for fresh juice shop, it would be possible to restrict the glass size to small, medium and large. This would make sure that it would not allow anyone to order any size other than the small, medium or large.

Comments

Popular posts from this blog

Constant in Java

Java History, Features and Application types