Java 8 - Primitive type Functional Interface for Consumer

Primitive type Functional Interface for Consumer:
1. IntConsumer
public void accept(int value)
2. LongConsumer
public void accept(long value)
3. DoubleConsumer
public void accept(double value)
4. ObjIntConsumer<T>
public void accept(T t,int value)
5. ObjLongConsumer<T>
public void accept(T t,long value)
6. ObjDoubleConsumer<T>
public void accept(T t,double value)
Example:
class Test
{
public static void main(String[] args)
{
IntConsumer c= i->System.out.println("The Square of i:"+(i*i));
c.accept(10);
}
}
Output: The Square of i:100

Comments

Popular posts from this blog

How to set Java Object into JaxBElement ?

GitLab