Java 8 ObjLongConsumer Interface

2 years ago Lalit Bhagtani 0

In this tutorial, we will learn about Java 8 ObjLongConsumer interface.

Java 8 ObjLongConsumer Interface

ObjLongConsumer Interface :-

ObjLongConsumer ( java.util.function.ObjLongConsumer ) 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 , long value ) :- The abstract method accept ( T t , long value ) is a functional method. It accepts two parameters as an argument ( one generic object and second long value ) and return no value, it performs the operation defined by the ObjLongConsumer interface ( usually a lambda expression passed as an argument ). 

Reference :-  ObjLongConsumer Interface JavaDocs 

Example :- 

In this example, we will declare a ObjLongConsumer interface that prints the value of a parameter passed as a argument.

  public static void main(String[] args){
    ObjLongConsumer<String> biConsumer = ( x , y ) -> { System.out.println(x + " " +y);};
    // Example of accept 

Result :- 

Interface 2 

That’s all for Java 8 ObjLongConsumer Interface. If you liked it, please share your thoughts in comments section and share it with others too.