{{theTime}}

Search This Blog

Total Pageviews

Java Enum and Variable argument Constructor Example


Create Enum class for Language and its shortcuts.
Enums are like classes and the constructor will allow variable arguments.
public enum Language{
    English("english", "eng", "en", "en_GB", "en_US","en_AU"),
    German("german", "de", "ge"),
    French("french", "fr", "frh"),

    private final List<String> values;

    Language(String ...values) {
        this.values = Arrays.asList(values);
    }

    public List<String> getValues() {
        return values;
    }
}

No comments:

Best Client Optimized Programming Language for Mobile Development?

Use Google's Dart language, which is Object-oriented, class-based and garbage-collected language with C-Style.  Dart can compile to eith...