How to declare a method parameter as any enum

public <E extends Enum<E>> void doSomething(E operation);

EDIT: An example according to your modifications:

public class Main {

    public enum Day {
        SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
        THURSDAY, FRIDAY, SATURDAY 
    }

    public <E extends Enum<E>> E doSomething(E operation, Class<E> klazz) {

        return operation;
    }

    public static void main(String[] args) {

        new Main().doSomething(Day.FRIDAY, Day.class);
    }

}

EDIT2:

if you need T and the Enum as separate types, then you’ll need:

public <T, E extends Enum<E>> T doSomething(E operation, Class<T> klazz) {

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)