Skip to content

Instantly share code, notes, and snippets.

@pramodpk89
Last active April 24, 2020 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pramodpk89/5c74096d48c8e687ab45927ef5d67f8f to your computer and use it in GitHub Desktop.
Save pramodpk89/5c74096d48c8e687ab45927ef5d67f8f to your computer and use it in GitHub Desktop.
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