Thursday, June 15, 2017

http://fahdshariff.blogspot.com/2016/06/java-8-completablefuture-vs-parallel.html

CompletableFutures provide more control over the size of the thread pool and should be used if your tasks involve I/O. However, if you're doing CPU-intensive operations, there's no point in having more threads than processors, so go for a parallel stream, as it is easier to use.

Saturday, June 3, 2017

String joining in Java 8


https://www.mkyong.com/java8/java-8-stringjoiner-example/

List<String> list = Arrays.asList("java", "python", "nodejs", "ruby");

//java | python | nodejs | ruby
String result = list.stream().map(x -> x).collect(Collectors.joining(" | "));

List<String> list = Arrays.asList("java", "python", "nodejs", "ruby");
  //java, python, nodejs, ruby
String result = String.join(", ", list);