Skip to main content
PreparationZone Logo
PreparationZone
Back to Java

Java · Medium · Pro

Strategy pattern with lambdas vs enum strategies?

JavaDesign PatternsSenior
Model answerPreview

Strategy pattern

The Strategy pattern encapsulates interchangeable algorithms behind a common interface so callers depend on behavior, not concrete classes. In modern Java, a Map<String, Runnable> or enum with lambdas often replaces a class hierarchy when strategies are stateless.

ApproachWhen it shinesWatch out