Friday

java - Enum as instance variables

public class Test {

    public enum MESSAGE {
        SUCCESS("1"),
        ERROR("2");

        private final String msg_id;

        private MESSAGE( final String msg_id ) {
            this.msg_id = msg_id;
        }

        public String getMsgId() {
             return msg_id;
        }
    }

    public static void main(String[] args) {
        System.out.println("MESSAGE.ERROR --> " + MESSAGE.ERROR.getMsgId());
    }

}

No comments:

Post a Comment