在Java 8中,是否有ByteStream类? [英] In Java 8, is there a ByteStream class?
问题描述
Java 8为 double
, int $提供
的等价物/stream/BaseStream.html\">文档。 Stream< T>
专精c $ c>和 long
: DoubleStream
, IntStream
和分别为 LongStream
。但是,我在 byte
Java 8 provides Stream<T>
specializations for double
, int
and long
: DoubleStream
, IntStream
and LongStream
respectively. However, I could not find an equivalent for byte
in the documentation.
Java 8是否提供 ByteStream
类?
Does Java 8 provide a ByteStream
class?
推荐答案
不,它不存在。实际上,它没有明确地实现,以免混乱使用大量类的Stream API用于每种基本类型。
No, it does not exist. Actually, it was explicitly not implemented so as not to clutter the Stream API with tons of classes for every primitive type.
引用邮件:
Quoting a mail from Brian Goetz in the OpenJDK mailing list:
简答:否。
Short answer: no.
每个JDK足迹不再是100K +对于这些形式
几乎从不使用。如果我们添加了那些,有人会
需求short,float或boolean。
It is not worth another 100K+ of JDK footprint each for these forms which are used almost never. And if we added those, someone would demand short, float, or boolean.
换句话说,如果人们坚持我们拥有所有原始的
专业化,我们没有原始的专业化。哪个
会比现状更差。
Put another way, if people insisted we had all the primitive specializations, we would have no primitive specializations. Which would be worse than the status quo.
这篇关于在Java 8中,是否有ByteStream类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!