fork download
  1. copy
  2. import java.util.stream.Stream;
  3.  
  4. import static java.util.Arrays.stream;
  5. import static java.util.stream.Collectors.joining;
  6.  
  7. public class Ideaone {
  8. public static String getRoute(String source, String destination, String... layovers) {
  9. final Stream<String> route = Stream.concat(Stream.of(source), Stream.concat(stream(layovers), Stream.of(destination))) ;
  10.  
  11. return route.peek(s -> {
  12. if (s.trim().isEmpty()) throw new IllegalArgumentException();
  13. }).collect(joining("->"));
  14. }
  15.  
  16. public static void main(String[] argv) {
  17. System.out.println(getRoute("JFK", "DEN","SFO", "LAX"));
  18. }
  19. }
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
copy
^
1 error
stdout
Standard output is empty