Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Using enum values as string literals

public enum Country{
    SPAIN("España"),
    ITALY("Italia"),
    PORTUGAL("Portugal");


    private String value;

    Country(final String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return this.getValue();
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Using #enum #values #string #literals
ADD COMMENT
Topic
Name
6+1 =