Benchmark: concatenate lists
Recently, I came across this piece of code that concatenates two lists using Guava’s Lists utility class and the Stream API: Lists.newArrayList(collectionOriginal,collectionValue) .stream() .flatMap(Collection::stream) .toList(); As this piece of code is in the hot path of the application and therefore called very frequently, I wondered if this was the best way to concatenate two lists. Two lists can be concatenated in many different ways: With the above code With Stream.concat() With Stream.of() With ListUtils from Apache Commons Collection With ArrayList.addAll()…