fork download
  1. import java.util.stream.IntStream;
  2.  
  3. enum Example {
  4. Red, Blue, Green, Yellow, Orange, Purple, Brown
  5. }
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. IntStream.range(0, Example.values().length)
  10. .filter(i -> i % 2 == 0)
  11. .forEach(i -> System.out.println(Example.values()[i]));
  12. }
  13. }
  14.  
Success #stdin #stdout 0.07s 48488KB
stdin
Standard input is empty
stdout
Red
Green
Orange
Brown