Most effective way to iterate over only the values from an Enum that begin with certain characters

You can make use of Streams from the enum’s values to filter out those you’re not interested in.

Arrays.stream(YourEnum.values())
    .filter(e -> e.name().startsWith("c_foo_"))
    .forEach(...);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top