java create lambda function parameter code example
Example 1: how to use lambda in java
StateOwner stateOwner = new StateOwner();
stateOwner.addStateListener(
(oldState, newState) -> System.out.println("State changed")
);
Example 2: java "->"
Runnable r = ()-> System.out.print("Run method");
// is equivalent to
Runnable r = new Runnable() {
@Override
public void run() {
System.out.print("Run method");
}
};