This article brings you a brief introduction to the function package in Java. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
There are a total of 43 interfaces under the function package. Well, it seems that there are still a lot of them. Don’t be afraid, in fact, there are only 5 categories to get the best results:
Function, Supplier, Consumer, Predicate, Operator. Judging from this, there are very few. That's not all, they have many similarities. If we classify and draw inferences based on these similarities, it will be much simpler. Here we first classify these 43 interfaces according to these common points:
Function class
Union: Function
original type
As parameters: DoubleFunction, IntFunction, LongFunction
As return values: ToDoubleFunction, ToIntFunction, ToLongFunction
Mutual conversion: DoubleToIntFunction, DoubleToLongFunction, IntToDoubleFunction, IntToLongFunction, LongToDoubleFunction, LongToIntFunction
Binary: BiFunction
Original type
As return value: ToDoubleBiFunction, ToIntBiFunction, ToLongBiFunction
Supplier classOne yuan: Supplier
Original type
As return value: BooleanSupplier, DoubleSupplier, IntSupplier, LongSupplier
Consumer class
One yuan: Consumer
Original type
As parameters:DoubleConsumer,IntConsumer,LongConsumer
Binary:BiConsumer
Original type
As parameters:ObjDoubleConsumer,ObjIntConsumer, ObjLongConsumer
Predicate class
One element: Predicate
Primitive type
As parameters: DoublePredicate, IntPredicate, LongPredicate
Binary: BiPredicate
Operator class
Uniary: UnaryOperator
Original type
As both parameter and return value: DoubleUnaryOperator, IntUnaryOperator, LongUnaryOperator
Binary: BinaryOperator
Primitive type
As both parameter and return value: DoubleBinaryOperator, IntBinaryOperator, LongBinaryOperator
The above is the detailed content of A brief introduction to the function package in Java. For more information, please follow other related articles on the PHP Chinese website!