Enum as a bounded type parameter

suggest change

When writing a class with generics in java, it is possible to ensure that the type parameter is an enum. Since all enums extend the Enum class, the following syntax may be used.

public class Holder<T extends Enum<T>> {
    public final T value;

    public Holder(T init) {
        this.value = init;

In this example, the type T must be an enum.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents