
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Implement ToIntBiFunction Using Lambda Expression in Java
ToIntBiFunction<T, U> is a built-in functional interface from java.util.function package. This interface accepts two parameters as input and produces an int-valued result. ToIntBiFunction<T, U> interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsInt() and doesn't contain any default or static methods.
Syntax
@FunctionalInterface interface ToIntBiFunction<T, U> { int applyAsInt(T t, U u); }
Example
import java.util.function.ToIntBiFunction; public class ToIntBiFunctionTest { public static void main(String args[]) { ToIntBiFunction<Integer, Integer> test = (t, u) -> t * u; System.out.println("The multiplication of t and u is: " + test.applyAsInt(10, 7)); System.out.println("The multiplication of t and u is: " + test.applyAsInt(8, 15)); } }
Output
The multiplication of t and u is: 70 The multiplication of t and u is: 120
Advertisements