In this example we will show you how to create an enum with a group of constants in Java.
Source Code
package com.beginner.examples;
enum Animal { // enum
DOG,
PIG,
CAT
}
public class EnumAnimal {
public static void main(String[] args) {
Animal e = Animal.CAT;
System.out.println(e);
}
}
Output:
CAT