About 628,000 results
Open links in new tab
  1. enum in Java - GeeksforGeeks

    Oct 4, 2024 · In Java, Enumerations or Java Enum serve the purpose of representing a group of named constants in a programming language. Java Enums are used when we know all possible values at compile time, such as choices on a menu, rounding modes, command-line flags, etc.

  2. Java Enums - W3Schools

    Enums. An enum is a special "class" that represents a group of constants (unchangeable variables, like final variables). To create an enum, use the enum keyword (instead of class or interface), and separate the constants with a comma. Note that they should be …

  3. A Guide to Java Enums - Baeldung

    Jan 5, 2024 · A quick and practical guide to the use of the Java Enum implementation, what it is, what problems it solves and how it can be used to implement commonly used design patterns.

  4. Enum Types (The Java™ Tutorials > Learning the Java Language …

    Java programming language enum types are much more powerful than their counterparts in other languages. The enum declaration defines a class (called an enum type). The enum class body can include methods and other fields. The compiler automatically adds some special methods when it creates an enum.

  5. Java Enum Constructor and Methods (with Examples)

    Oct 3, 2023 · Java enum example. The purpose of enum is to enforce compile time type safety. Learn enum constructors, methods, inheritance, EnumMap and EnumSet etc.

  6. Java enum & enum Class (With Examples) - Programiz

    In Java, an enum (short for enumeration) is a type that has a fixed set of constant values. We use the enum keyword to declare enums. For example, enum Size { SMALL, MEDIUM, LARGE, EXTRALARGE } Here, we have created an enum named Size. It contains fixed values SMALL, MEDIUM, LARGE, and EXTRALARGE.

  7. Enum in Java - DigitalOcean

    Aug 3, 2022 · Enum was introduced in Java 1.5 as a new type whose fields consists of a fixed set of constants. For example, we can create directions as Java Enum with fixed fields as EAST, WEST, NORTH, and SOUTH. Java Enum. In this tutorial, …

  8. Enums in Java - Java Guides

    An enum type is a special data type that enable for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.

  9. Comprehensive Guide to Enums in Java | by Pratik T - Medium

    Sep 8, 2024 · Enums in Java are a powerful and flexible tool that provides type-safe, readable, and efficient ways to define a fixed set of constants.

  10. Understanding Enums(Class) in Java: A Step-by-Step Guide

    Jan 24, 2025 · Enums in Java are a powerful and efficient way to handle fixed sets of constants. They offer numerous benefits such as type safety, built-in methods ( values() , ordinal() , etc.), and the ability to add fields and methods to store more data alongside each constant.