fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.lang.*;
  6. import java.io.*;
  7. import java.util.Arrays;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. // Stream<String> fruitStream = Stream.of("apple", "banana", "pear", "kiwi", "orange");
  15.  
  16. // fruitStream.filter(s -> s.contains("a"))
  17. // .map(String::toUpperCase)
  18. // .sorted()
  19. // .forEach(System.out::println);
  20.  
  21. Stream<String> fruitStream = Stream.of("apple", "banana", "pineapple", "mango", "guava", "grapes");
  22.  
  23. fruitStream.filter(x -> x.contains("a"))
  24. .map(String::toUpperCase)
  25. .sorted()
  26. .forEach(System.out::println);
  27.  
  28. // try(Stream<String> lines = Files.lines(Paths.get("some_path"))){
  29. // lines.forEach(System.out::println);
  30. // }
  31.  
  32. // Stream.onClose("sdsf");
  33.  
  34. List<Integer> intStream = Arrays.asList(1, 2, 5, 4, 8 ,9, 7);
  35. intStream.stream().filter(x -> (x & 1) == 1).forEach(System.out::println);
  36.  
  37.  
  38. }
  39.  
  40. // public Stream<String> streamAndDelete(Path path) throws IOExecption {
  41. // return Files.lines(path).onClose(() -> someClass.deletePath(path));
  42. // }
  43. }
Success #stdin #stdout 0.14s 56188KB
stdin
Standard input is empty
stdout
APPLE
BANANA
GRAPES
GUAVA
MANGO
PINEAPPLE
1
5
9
7