Java 8 — BiConsumer | Code Factory

Index Page : Link

Reference Link : Link

Donate : Link

Normal Consumer can take only one input argument and perform required operation and won’t return any result.

But sometimes our programming requirement to accept 2 input values and perform required operation and not required to return any result. Then we should go for BiConsumer.

BiConsumer is exactly same as Consumer except that it will take 2 input arguments.

Program to accept 2 String values and print result of concatenation by using BiConsumer :

Output :

Demo Program to increment employee Salary by using BiConsumer :

Output :

Comparison Table between One argument and Two argument Functional Interfaces :

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store