Java switch statement

Imagine that you're a knight stopped at a fork in the road. If you go left, you will lose your horse. If you go right, you will gain knowledge. How would we represent this situation in code? You probably already know that we use constructs like if-then and if-then-else to make these decisions. But what if the road splits not into two, but into ten?

You have roads that are "completely to the right", "slightly to the left of that", "a little bit more to the left" and so on, totaling 10 possible roads? Imagine how your "if-then-else" code will grow in this version! Suppose you have a 10-way fork in the road. For such situations, Java has the switch statement. We'll talk about this fellow several more times.

Enum. Practical examples. Adding constructors and methods

And a few more words about Enum. More precisely, fewer words, but more code and practice. After all, the brains of many people are (quite often) full of mush on this topic rather than knowledge. If you want to get a better feel for the topic, don't be shy: feel free to read and explore as you go.