Why there is no BooleanConsumer in Java 8?

后端 未结 3 1105
囚心锁ツ
囚心锁ツ 2021-02-05 00:04

I\'m afraid that this is somewhat a silly question.

Is there anybody can tell me why there is no BooleanConsumer opposite to BooleanSupplier?

Is the

3条回答
  •  盖世英雄少女心
    2021-02-05 00:37

    IntConsumer and LongConsumer are needed to avoid the overhead autoboxing every value. It is much more efficent to be working on raw primitives. However, for Boolean and Byte every possible object is cached so there is little reason to avoid using Consumer or Consumer

提交回复
热议问题