O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java Enumerations Are Class Types

Although the preceding examples show the mechanics of creating and using an enumeration, they don’t show all of its capabilities. Unlike the way enumerations are implemented in some other languages, Java implements enumerations as class types. Although you don’t instantiate an enum using new, it otherwise acts much like other classes. The fact that enum defines a class enables the Java enumeration to have powers that enumerations in some other languages do not. For example, you can give it constructors, add instance variables and methods, and even implement interfaces.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required