Never miss a beat

Join my newsletter.

Tag: enums

A Beginner's Guide to Java Enums

Published: 8/5/2019

An Enum in Java is a special data type that encompasses a set of predefined constants. When setting a variable of that Enum type, you have to use one of the constants that you define for it. A great example is the compass: In the above example, we create a new enum and it’s predefined set of constants. Then we create a variable of that enum type, and assign it to one of the constants. Keep in mind that we can only set our direction to Compass.NORTH , Compass.SOUTH , Compass.EAST , Compass…