Why don't primitive Stream have collect(Collector)?

后端 未结 5 1374
-上瘾入骨i
-上瘾入骨i 2020-12-14 06:36

I\'m writing a library for novice programmers so I\'m trying to keep the API as clean as possible.

One of the things my Library needs to do is perform some complex c

5条回答
  •  旧时难觅i
    2020-12-14 07:24

    We did in fact prototype some Collector.OfXxx specializations. What we found -- in addition to the obvious annoyance of more specialized types -- was that this was not really very useful without having a full complement of primitive-specialized collections (like Trove does, or GS-Collections, but which the JDK does not have). Without an IntArrayList, for example, a Collector.OfInt merely pushes the boxing somewhere else -- from the Collector to the container -- which no big win, and lots more API surface.

提交回复
热议问题