Enumerated Type Definition & Meaning

In programming, an enum, short for enumerated type, is a user-defined data type consisting of a set of named values called enumerators. Instead of using an integer to represent a set of values, a type with a restricted set of values is used instead. Using enums increases the level of abstraction and lets the programmer focus on the value’s meaning instead of its storage and accessibility. This, in turn, reduces bugs.

Think of the four suits in a deck of playing cards clubs, diamonds, hearts, and spades as four enumerators belonging to an enumerated type named suit. If a variable V is declared having suit as its data type, one can assign any one of those four values (clubs, diamonds, hearts, and spades) to it.

Values and variables of an enum are implemented as fixed-length bit strings that are compatible in format and size with some integer type. In type theory, enums are considered as tagged unions of unit types. Programming languages that use enums include Pascal, Java, and C#.

Enum benefits

Enums provide the following benefits:

  • They are a constant rather than a number, increasing readability of the source code.
  • They provide compile-time type safety and prevent comparing constants in different enums. A function argument, return type, class member, or local variable can be declared as an enum type and the compiler will enforce type safety.
  • Enums group things into a set.
  • In Java, enumeration can be used as a singleton. A single element enum type is considered one of the best ways to implement a singleton.






Abby Dykes
Abby Dykes
Abby Dykes is a newly-graduated writer and editor for websites such as TechnologyAdvice.com, Webopedia.com, and Project-Management.com. When she’s not writing about technology, she enjoys giving too many treats to her dog and coaching part-time at her local gym.

Top Articles

Huge List Of Texting and Online Chat Abbreviations

From A3 to ZZZ we list 1,559 text message and online chat abbreviations to help you translate and understand today's texting lingo. Includes Top...

How To Create A Desktop Shortcut To A Website

This Webopedia guide will show you how to create a desktop shortcut to a website using Firefox, Chrome or Internet Explorer (IE). Creating a desktop...

The History Of Windows Operating Systems

Microsoft Windows is a family of operating systems. We look at the history of Microsoft's Windows operating systems (Windows OS) from 1985 to present...

Hotmail [Outlook] Email Accounts

  By Vangie Beal Hotmail is one of the first public webmail services that can be accessed from any web browser. Prior to Hotmail and its...

Unregulated Power Supply Definition...

An unregulated power supply is a system that transforms input voltage into direct...

Cybersecurity Awareness Training Definition...

Cybersecurity awareness training informs employees of the attack surfaces and vectors in their...

OST File Definition &...

An OST file, or offline storage table (.ost) file, is an Offline Outlook...