Java 8 ObjIntConsumer Interface
7 years ago Lalit Bhagtani 0
In this tutorial, we will learn about Java 8 ObjIntConsumer interface.
ObjIntConsumer Interface :-
ObjIntConsumer ( java.util.function.ObjIntConsumer ) is a functional interface that has one abstract method declared in it. This interface is a specialised form of BiConsumer interface.
Abstract method :-
void accept ( T t , int value ) :- The abstract method accept ( T t , int value ) is a functional method. It accepts two parameters as an argument ( one generic object and second int value ) and return no value, it performs the operation defined by the ObjIntConsumer interface ( usually a lambda expression passed as an argument ).
Reference :- ObjIntConsumer Interface JavaDocs
Example :-
In this example, we will declare a ObjIntConsumer interface that prints the value of a parameter passed as a argument.
public static void main(String[] args){ ObjIntConsumer<String> biConsumer = ( x , y ) -> { System.out.println(x + " " +y);}; // Example of accept biConsumer.accept("Interface",2); }
Result :-
Interface 2
That’s all for Java 8 ObjIntConsumer interface. If you liked it, please share your thoughts in comments section and share it with others too.