java enum

  1. Generated constructor is private, there’s no way to create new enum instance if not list in the class.
  2. enum values are static fields of the class.
  3. enum class extends abstract class Enum<T extends Enum<T>> after compilation.
  4. enum could be used to define constant class as its constructor is private.
public enum EnumColor {
  Yellow("Yellow"), Red("Red");
  private String color;
  EnumColor(String color) {
    this.color = color;
  } 
  public String getColor() {
    return color;
  }
  public static void main(String ...args) {
    System.out.println(Yellow.getColor());   
  }
}

enum Constants {
	;
	public static String CONF = "app.conf";
	public static int ARRAY_CAP = 16;
}