java neutral lambda table expression use 1
1, lambda table expression type in java, possible meeting charge anonymous internal type 2, java neutral function tangent (Functional Interface commentary) Note: Function interface, one-of-a-kind abstraction method, one-of-a-kind method, anonymous method, lambda expression
lamda table form replacement fee anonymous internal type method
@FunctionalInterface
interface ExecuteAble{
void say(String name,String msg);
}
public class RobotT{
public void say(ExecuteAble exe){
exe.say("Robot Lucy "," is laughing hahahaha......");
}
}
public class TestLambda{
public static void main (String[] args){
Robot t1 _new Robot();
t1.say(
(name,msg) -> {
system.out.println(name + msg);
} );
Robot t2 _new Robot();
//change the contents of saying
//annomous inner class
t2.say(new ExecuteAble(){
public void say(String name,String msg){
system.out.println(name + msg);
}
})
}
}
Recommended Posts