Javatpoint Logo
Javatpoint Logo

Higher order function

High order function (Higher level function) is a function which accepts function as a parameter or returns a function or can do both. Means, instead of passing Int, String, or other types as a parameter in a function we can pass a function as a parameter in other function.

Let's see the following example:

In this above example, we defined a function myFun() with three parameters. The first and second parameter take String and the third parameter as a type of function from String to String. The parameter String to String type means function takes string as an input and returns output as string types.

To call this above function, we can pass function literal or lambda. For example:

Output:

sssit.org develop javatpoint.com

The above higher order function can also be called in another ways as below mention code in main() function:

myFun("sssit.org","javatpoint.com",{org,portal->"$org develop $portal"})






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA