The ObjIntConsumer Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in two arguments and produces a result. However these kind of functions don’t return any value.
Hence this functional interface takes in one generic namely:-
- T: denotes the type of the input argument to the operation
The lambda expression assigned to an object of ObjIntConsumer type is used to define its accept() which eventually applies the given operation on its argument. It takes in a int-valued and a T-valued argument and is expected to operate without any side effects. It is more like using an object of type BiConsumer<T, Int> except the fact that one is a reference and one is a primitive data type in this case. Hence we will be obtaining one reference and one value when this function is called.
Functions in ObjIntConsumer Interface
The ObjIntConsumer interface consists of the following two functions:
This method accepts two values and performs the operation on the given arguments.
void accept(T t, int value)
Parameters: This method takes in two parameters:
- t– the first input argument
- value– the second input argument
Return Value: This method does not return any value.
Below is the code to illustrate accept() method:
6 4 10 14 8
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- Map Interface in Java
- Java 8 | BiConsumer Interface in Java with Examples
- Java 8 | IntToDoubleFunction Interface in Java with Examples
- Java 8 | DoubleToLongFunction Interface in Java with Examples
- Java 8 | IntToLongFunction Interface in Java with Examples
- Java 8 | Consumer Interface in Java with Examples
- BlockingQueue Interface in Java
- ConcurrentMap Interface in java
- Java 8 | ObjLongConsumer Interface with Example
- Java 8 | ObjDoubleConsumer Interface with Example
- Map.Entry interface in Java with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.