Java doesn’t have the concept of delegate; instead, if you need a pointer to a function, you can create inline anonymous classes (or lambda expressions as of Java 8 ) which are implementations of certain interfaces designed for this propose (a.k.a functional interfaces as of Java 8). However as Java evolves, more of such interfaces are being added. While they may seem very similar and confusing, each of them has a unique characteristic which sets it apart from the others. You can map many of them to identical types in .NET. The following table lists some of the famous interfaces but there are many more. For example to support functions with two arguments, Java has another interface called BiFunction and if you need more arguments, you have to create your own interfaces. Remember that Java (up to version 10) doesn’t support identical class names if the only difference is number of type arguments. (In .NET there are various Func and Action types with up to 16 type arguments.)
|Java||Supports Exceptions||Argument||Returns||.NET Equivalent|
Thank you for sharing.
But I think the Provider is not standard API/Function in Java (yet). Maybe UnaryOperator or Predicate ?
UnaryOperator –> Function
Predicate –> Function
You are right, thanks for the comment. I just updated the post.