xxxxxxxxxx
public interface MyInterface {
String doSomething(int param1, String param2);
}
class MyClass {
public MyInterface myInterface = (p1, p2) -> { return p2 + p1; };
}
new Thread(this::someMethod).start();
xxxxxxxxxx
//passing a function as param and calling that function
function goToWork(myCallBackFunction) {
//do some work here
myCallBackFunction();
}
function refreshPage() {
alert("I should be refreshing the page");
}
goToWork(refreshPage);
xxxxxxxxxx
function sayHello() {
return "Hello, ";
}
function greeting(helloMessage, name) {
console.log(helloMessage() + name);
}
// Pass `sayHello` as an argument to `greeting` function
greeting(sayHello, "JavaScript!");
// Hello, JavaScript!