Enums in Java
Type-safe sets of constants that can have fields, constructors and methods.
Easy
enum Unit { VOLT("V"), AMP("A"); final String symbol; Unit(String s) { symbol = s; } }
Use EnumMap and EnumSet for efficient enum collections.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.