-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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