fork(3) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.stream.*;
  5.  
  6. class Ideone
  7. {
  8. public static String doSomethingWith(String x)
  9. {
  10. return "not asterisk";
  11. }
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. String[] A = new String[] { "one", "two", "*" };
  15. String[] B = new String[] { "four", "five", "*" };
  16. List<String> myList= new ArrayList<>(A.length + B.length);
  17.  
  18. myList = IntStream.range(0, B.length)
  19. .mapToObj(i -> new String[]
  20. {
  21. A[i],
  22. "*".equals(B[i]) ? B[i] : doSomethingWith(B[i])
  23. })
  24. .flatMap(a -> Arrays.stream(a))
  25. .collect(Collectors.toList());
  26.  
  27. for (String s : myList)
  28. System.out.println(s);
  29. }
  30. }
Success #stdin #stdout 0.13s 4575232KB
stdin
Standard input is empty
stdout
one
not asterisk
two
not asterisk
*
*