package com.demo; public enum TestEnum { A("hello"), B("world"); private String value; private TestEnum(String value){ this.value = value; } public String getValue(){ return value; } @Override public String toString() { return value; } public static void main(String[] args){ System.out.println(TestEnum.valueOf("A")); System.out.println(TestEnum.A); } }