Skip to content

Instantly share code, notes, and snippets.

@pramodpk89

pramodpk89/BiConsumerExample.java Secret

Last active Apr 24, 2020
Embed
What would you like to do?
Creates a biConsumer which accepts to integers and eveluates if they are even or not.
package com.ppkcodes;
import java.util.function.BiConsumer;
/**
* This class shows accept implementation of BiConsumer
*/
public class BiConsumerExample {
public static void main(String[] args) {
BiConsumer<Integer,Integer> evenCheck=(i,j)->{
System.out.println("INPUT: arguements are "+i +" & "+j);
Boolean first=false;Boolean second=false;
if(i%2==0) first=true;
if(j%2==0)second=true;
if (first & second) System.out.println("RESULT: Both parameters are even");
if((first & !second) || (!first & second)) System.out.println("Only one parameters are even");
if(!first & !second)System.out.println("Both parameters are not even");
};
evenCheck.accept(2,4);
evenCheck.accept(3,4);
evenCheck.accept(10,11);
evenCheck.accept(11,13);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.