You can learn Java with me as the Java Programming language is being made easily. It would take a period of minimum three months and maximum 6 months to master Java. I would recommend you to watch all my videos to crack any software interviews that would require Java Programming language as a primary skill.
Primitive versions for Consumer and Supplier:-
=============================================
Primitive versions for Consumer:-
================================
Please be informed that the Consumer T interface represents an operation that takes a single input argument and returns no result. For primitive types like int, double, and long, there are specialized functional interfaces to avoid the overhead of boxing and unboxing that occurs with their object counterparts.
Here are the primitive versions of Consumer in the java.util.function package:
Primitive Versions of Consumer:-
================================
1.IntConsumer: For int values
2.DoubleConsumer: For double values
3.LongConsumer: For long values
4.ObjIntConsumer T: For an object of type T and an int value
5.ObjDoubleConsumer T: For an object of type T and a double value
6.ObjLongConsumer T: For an object of type T and a long value
Primitive versions for Supplier :-
==========================
Please be informed that the Supplier T interface is designed to work with any type of object. However, for primitive types like int, double, or boolean, the Java standard library provides specialized functional interfaces to avoid the overhead of boxing and unboxing that occurs with their object counterparts.
Here’s how Java handles primitive types with functional interfaces:
Primitive Versions of Supplier
1.IntSupplier: For int values
2.DoubleSupplier: For double values
3.LongSupplier: For long values
4. BooleanSupplier: For boolean values
These interfaces are part of the java.util.function package and help you work with primitive types more efficiently.
These specialized suppliers provide a way to work with primitive types in a way that avoids the need for boxing, making them more efficient for performance-critical code. Each of these functional interfaces provides a single method to retrieve a primitive value, and they fit well with lambda expressions and method references in Java.
Негізгі бет Java 8 features - class 20- Primitive versions for Consumer and Supplier interfaces
Пікірлер: 1