Tuesday, March 26, 2013

Java;Notes - 11.) Java Enumeration

In java there are many ways to set up a variable to mean something. However setting up some variables can be tedious and give way to issues later on down the line. This is where Enumeration seems to come into play.
Enumeration can be defined as a way to make a custom static variable but in most cases it is a string of variables that will have certain meanings.

Say for instance you are looking to organize your clothing by Size. Instead of it being a set of characters or numbers why not make it an enumeration like so:

Then you will be able to declare variables of this type such as:
Size s = Size.MEDIUM 

In the end enumeration serves as a wonderful way to keep things organized and give another level of customization.

No comments:

Post a Comment