Home › coding › java › java enum

Java Enum — Free Java Tutorial

Learn Java Enum in Java with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

✓ 100% Free ✓ No Login Needed ✓ NCERT / CBSE Aligned ✓ Download as PDF

TL;DR: Learn Java Enum in Java with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated Jul 14, 2026

🤖 Stuck on any question? Ask Syllab's free AI Tutor for a step-by-step explanation — instant, unlimited, no login.

Java Enum in Java

An enum (enumeration) defines a fixed set of named constants. Use it when a variable can only hold one of a limited set of values: days of the week, directions, seasons, status codes.

Enums are type-safe — the compiler prevents assigning invalid values, unlike using int constants (0, 1, 2...).

Java enums are full classes — they can have fields, constructors, and methods. This makes them far more powerful than enums in other languages.

Useful enum methods: values() returns all constants as an array, ordinal() returns the position (0-based), name() returns the name as a String, valueOf(String) converts a string to an enum constant.

Java Enum — Syntax

// Basic enum
enum Direction { NORTH, SOUTH, EAST, WEST }

// Enum with fields
enum Priority {
    LOW(1), MEDIUM(5), HIGH(10);
    private final int value;
    Priority(int value) { this.value = value; }
    public int getValue() { return value; }
}

Direction dir = Direction.NORTH;
for (Direction 

Learn Java Enum step by step with Syllab's free interactive Java tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Java course →

Explore:

  • Syllabus
  • Practice
  • Mock Tests
  • NCERT Solutions
  • Coding
  • GK Quiz
  • Career Predictor
  • AI Tutor
  • Live Quiz
  • Doubt Solver
  • Microlearning
  • Free Alternatives
  • Kids Zone
  • Study Room
  • Calculators
  • Worksheets

Syllab.in — Free learning for Indian students, Class 1–12