Stream is an interface so whenever one gets hold of a Stream object there are lots of implementation specific details hidden.

For example, take the following code:

List<String> list = new ArrayList<>(); ... int size = list.stream() .count();

Does it run in constant or linear time? Or this:

Set<String> set = new TreeSet<>(); ... set.stream() .sorted() .forEach(System.out::println);

Would that be O(n) or O(n log n)?

In general, how specialized are the streams implementations returned by the standard collections?