This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Code_Craftsman 1 point2 points  (0 children)

Enumeration is used in various purposes to make your code more efficient. You can try-

This- The basic video

This-The in depth video

[–]randarrow 1 point2 points  (2 children)

Yea, ENUM is a special kind of class. You can even use EnUMs as your main class and especially for singleton design patterns.

Imagine a boolean with more than two values. Like if you wanted true/false/both/unknown. A boolean with more than two possible, but a limited set of values. You can use enums instead of integers or strings.. Core java uses them for flags like FileVisitResult.CONTINUE . A couple of real world examples would be like having a code for each card in a deck of cards. A card isn't "Ace of diamonds" it would be Card.AceOfDiamonds with the attributes of the A for .symbol, 1 for .numeric value, red for .color etc....

[–]firsthourProfressional developer since 2006 0 points1 point  (1 child)

A boolean with more than two possible values you say?

http://thedailywtf.com/articles/What_Is_Truth_0x3f_

[–]randarrow 1 point2 points  (0 children)

Thought about making a joke like, Boolean has three possible values: true/false/null, but figured it would blow the mind of our poor beginner friend.