Enum<?> represents a generic reference to any enum type in Java. The wildcard (?) indicates an unknown enum type, allowing the Enum class to operate on all enum types in a type-safe manner without requiring knowledge of a specific enum. This generic design enables Java's enum infrastructure to provide common behavior for every enum while preserving compile-time type safety.
Suppose an application processes different enums such as PaymentStatus, OrderStatus, and UserRole. Using Enum<?> allows generic code to handle all of them without creating separate logic for each enum type.
enum OrderStatus {
NEW, PROCESSING, COMPLETED
}
enum PaymentStatus {
PENDING, SUCCESS, FAILED
}
public class Main {
public static void printEnumInfo(
Enum<?> value) {
System.out.println(
"Name: " + value.name());
System.out.println(
"Ordinal: " + value.ordinal());
}
public static void main(String[] args) {
printEnumInfo(OrderStatus.NEW);
printEnumInfo(PaymentStatus.SUCCESS);
}
}A concise interview answer is: Enum<?> is a generic representation of any enum type, where ? is a wildcard indicating an unknown enum. It allows the Enum base class to provide common functionality for all enums while maintaining type safety and flexibility through Java generics.
Last updated: 11 November 2026
Previous question: Your logs show an OutOfMemoryError. How would you investigate it?
Next question: How can we implement singleton and strategy patterns using enum?