Java Enum

In Java, an enum (short for “enumeration”) is a special data type that defines a set of named constants, also known as enum constants or enumerators. Enumerations provide a way to define a finite set of values that a variable can take on.

Enum constants are typically used to represent a predefined list of related values or options.

Related Tags

Tutorials

Java learning path diagram with 12 numbered steps in three stages, from language basics and OOP to collections, exceptions, generics, streams, concurrency, I/O, date and time, modern Java features and JUnit tests

Java Core & Fundamentals Tutorial

Java tutorial for beginners on Java 25. Install the JDK, run a first program and follow a 12-step learning path plus an index of every Java topic.

Java Enum with String Values: Create, Convert and Lookup

Learn to create a Java enum with String values, convert an enum to a String with name(), toString() or a getter, and convert a String back to an enum safely with valueOf() or a case-insensitive lookup that returns Optional.

Java Enum Tutorial: What Is an Enum, Constructors, Methods

An enum is a data type with a fixed set of named constants. This Java enum tutorial covers declaring enums, values(), valueOf(), ordinal() and name(), switch and pattern matching on Java 25, constructors, fields and methods, EnumSet, EnumMap, singletons and safe String-to-enum conversion.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.