fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.stream.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. List<Integer> result = IntStream.rangeClosed(1, 10)
  14. .boxed()
  15. .flatMap((i) -> {
  16. List<Integer> results = new ArrayList<>();
  17. if (10 % i == 0) {
  18. results.add(i);
  19. if (i != 5) {
  20. results.add(10 / i);
  21. }
  22. }
  23. return results.stream();
  24. })
  25. .collect(Collectors.toList());
  26. result.forEach(System.out::println);
  27. }
  28. }
Success #stdin #stdout 0.2s 320576KB
stdin
Standard input is empty
stdout
1
10
2
5
5
10
1